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

@@ -1,6 +1,8 @@
package org.bukkit.event;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.jetbrains.annotations.NotNull;
/**
* Represents an event.
@@ -40,6 +42,7 @@ public abstract class Event {
*
* @return name of this event
*/
@NotNull
public String getEventName() {
if (name == null) {
name = getClass().getSimpleName();
@@ -47,6 +50,7 @@ public abstract class Event {
return name;
}
@NotNull
public abstract HandlerList getHandlers();
/**

View File

@@ -2,6 +2,7 @@ package org.bukkit.event;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredListener;
import org.jetbrains.annotations.NotNull;
import java.util.*;
import java.util.Map.Entry;
@@ -63,7 +64,7 @@ public class HandlerList {
*
* @param plugin plugin to unregister
*/
public static void unregisterAll(Plugin plugin) {
public static void unregisterAll(@NotNull Plugin plugin) {
synchronized (allLists) {
for (HandlerList h : allLists) {
h.unregister(plugin);
@@ -76,7 +77,7 @@ public class HandlerList {
*
* @param listener listener to unregister
*/
public static void unregisterAll(Listener listener) {
public static void unregisterAll(@NotNull Listener listener) {
synchronized (allLists) {
for (HandlerList h : allLists) {
h.unregister(listener);
@@ -104,7 +105,7 @@ public class HandlerList {
*
* @param listener listener to register
*/
public synchronized void register(RegisteredListener listener) {
public synchronized void register(@NotNull RegisteredListener listener) {
if (handlerslots.get(listener.getPriority()).contains(listener))
throw new IllegalStateException("This listener is already registered to priority " + listener.getPriority().toString());
handlers = null;
@@ -116,7 +117,7 @@ public class HandlerList {
*
* @param listeners listeners to register
*/
public void registerAll(Collection<RegisteredListener> listeners) {
public void registerAll(@NotNull Collection<RegisteredListener> listeners) {
for (RegisteredListener listener : listeners) {
register(listener);
}
@@ -127,7 +128,7 @@ public class HandlerList {
*
* @param listener listener to remove
*/
public synchronized void unregister(RegisteredListener listener) {
public synchronized void unregister(@NotNull RegisteredListener listener) {
if (handlerslots.get(listener.getPriority()).remove(listener)) {
handlers = null;
}
@@ -138,7 +139,7 @@ public class HandlerList {
*
* @param plugin plugin to remove
*/
public synchronized void unregister(Plugin plugin) {
public synchronized void unregister(@NotNull Plugin plugin) {
boolean changed = false;
for (List<RegisteredListener> list : handlerslots.values()) {
for (ListIterator<RegisteredListener> i = list.listIterator(); i.hasNext();) {
@@ -156,7 +157,7 @@ public class HandlerList {
*
* @param listener listener to remove
*/
public synchronized void unregister(Listener listener) {
public synchronized void unregister(@NotNull Listener listener) {
boolean changed = false;
for (List<RegisteredListener> list : handlerslots.values()) {
for (ListIterator<RegisteredListener> i = list.listIterator(); i.hasNext();) {
@@ -186,6 +187,7 @@ public class HandlerList {
*
* @return the array of registered listeners
*/
@NotNull
public RegisteredListener[] getRegisteredListeners() {
RegisteredListener[] handlers;
while ((handlers = this.handlers) == null) bake(); // This prevents fringe cases of returning null
@@ -199,7 +201,8 @@ public class HandlerList {
* @param plugin the plugin to get the listeners of
* @return the list of registered listeners
*/
public static ArrayList<RegisteredListener> getRegisteredListeners(Plugin plugin) {
@NotNull
public static ArrayList<RegisteredListener> getRegisteredListeners(@NotNull Plugin plugin) {
ArrayList<RegisteredListener> listeners = new ArrayList<RegisteredListener>();
synchronized (allLists) {
for (HandlerList h : allLists) {
@@ -223,6 +226,7 @@ public class HandlerList {
* @return the list of all handler lists
*/
@SuppressWarnings("unchecked")
@NotNull
public static ArrayList<HandlerList> getHandlerLists() {
synchronized (allLists) {
return (ArrayList<HandlerList>) allLists.clone();

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.jetbrains.annotations.NotNull;
/**
* Called when a block is broken by a player.
@@ -30,7 +31,7 @@ public class BlockBreakEvent extends BlockExpEvent implements Cancellable {
private boolean dropItems;
private boolean cancel;
public BlockBreakEvent(final Block theBlock, final Player player) {
public BlockBreakEvent(@NotNull final Block theBlock, @NotNull final Player player) {
super(theBlock, 0);
this.player = player;
@@ -42,6 +43,7 @@ public class BlockBreakEvent extends BlockExpEvent implements Cancellable {
*
* @return The Player that is breaking the block involved in this event
*/
@NotNull
public Player getPlayer() {
return player;
}

View File

@@ -3,6 +3,8 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when a block is destroyed as a result of being burnt by fire.
@@ -16,11 +18,11 @@ public class BlockBurnEvent extends BlockEvent implements Cancellable {
private final Block ignitingBlock;
@Deprecated
public BlockBurnEvent(final Block block) {
public BlockBurnEvent(@NotNull final Block block) {
this(block, null);
}
public BlockBurnEvent(final Block block, final Block ignitingBlock) {
public BlockBurnEvent(@NotNull final Block block, @Nullable final Block ignitingBlock) {
super(block);
this.ignitingBlock = ignitingBlock;
}
@@ -31,6 +33,7 @@ public class BlockBurnEvent extends BlockEvent implements Cancellable {
* @return The Block that ignited and burned this block, or null if no
* source block exists
*/
@Nullable
public Block getIgnitingBlock() {
return ignitingBlock;
}
@@ -43,11 +46,13 @@ public class BlockBurnEvent extends BlockEvent implements Cancellable {
this.cancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -5,6 +5,8 @@ import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when we try to place a block, to see if we can build it here or not.
@@ -25,7 +27,7 @@ public class BlockCanBuildEvent extends BlockEvent {
private final Player player;
@Deprecated
public BlockCanBuildEvent(final Block block, final BlockData type, final boolean canBuild) {
public BlockCanBuildEvent(@NotNull final Block block, @NotNull final BlockData type, final boolean canBuild) {
this(block, null, type, canBuild);
}
@@ -36,7 +38,7 @@ public class BlockCanBuildEvent extends BlockEvent {
* @param type the id of the block to place
* @param canBuild whether we can build
*/
public BlockCanBuildEvent(final Block block, final Player player, final BlockData type, final boolean canBuild) {
public BlockCanBuildEvent(@NotNull final Block block, @Nullable final Player player, @NotNull final BlockData type, final boolean canBuild) {
super(block);
this.player = player;
this.buildable = canBuild;
@@ -70,6 +72,7 @@ public class BlockCanBuildEvent extends BlockEvent {
*
* @return The Material that we are trying to place
*/
@NotNull
public Material getMaterial() {
return blockData.getMaterial();
}
@@ -79,6 +82,7 @@ public class BlockCanBuildEvent extends BlockEvent {
*
* @return The BlockData that we are trying to place
*/
@NotNull
public BlockData getBlockData() {
return blockData;
}
@@ -90,15 +94,18 @@ public class BlockCanBuildEvent extends BlockEvent {
*
* @return The Player who placed the block involved in this event
*/
@Nullable
public Player getPlayer() {
return player;
}
@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;
/**
* Called when a block is damaged by a player.
@@ -18,7 +19,7 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable {
private boolean cancel;
private final ItemStack itemstack;
public BlockDamageEvent(final Player player, final Block block, final ItemStack itemInHand, final boolean instaBreak) {
public BlockDamageEvent(@NotNull final Player player, @NotNull final Block block, @NotNull final ItemStack itemInHand, final boolean instaBreak) {
super(block);
this.instaBreak = instaBreak;
this.player = player;
@@ -31,6 +32,7 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable {
*
* @return The player damaging the block involved in this event
*/
@NotNull
public Player getPlayer() {
return player;
}
@@ -60,6 +62,7 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable {
*
* @return The ItemStack for the item currently in the player's hand
*/
@NotNull
public ItemStack getItemInHand() {
return itemstack;
}
@@ -72,11 +75,13 @@ public class BlockDamageEvent extends BlockEvent 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.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
/**
* Called when an equippable item is dispensed from a block and equipped on a
@@ -16,7 +17,7 @@ public class BlockDispenseArmorEvent extends BlockDispenseEvent {
private final LivingEntity target;
public BlockDispenseArmorEvent(Block block, ItemStack dispensed, LivingEntity target) {
public BlockDispenseArmorEvent(@NotNull Block block, @NotNull ItemStack dispensed, @NotNull LivingEntity target) {
super(block, dispensed, new Vector(0, 0, 0));
this.target = target;
}
@@ -26,6 +27,7 @@ public class BlockDispenseArmorEvent extends BlockDispenseEvent {
*
* @return the target entity
*/
@NotNull
public LivingEntity getTargetEntity() {
return target;
}

View File

@@ -5,6 +5,7 @@ import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
/**
* Called when an item is dispensed from a block.
@@ -18,7 +19,7 @@ public class BlockDispenseEvent extends BlockEvent implements Cancellable {
private ItemStack item;
private Vector velocity;
public BlockDispenseEvent(final Block block, final ItemStack dispensed, final Vector velocity) {
public BlockDispenseEvent(@NotNull final Block block, @NotNull final ItemStack dispensed, @NotNull final Vector velocity) {
super(block);
this.item = dispensed;
this.velocity = velocity;
@@ -31,6 +32,7 @@ public class BlockDispenseEvent extends BlockEvent implements Cancellable {
*
* @return An ItemStack for the item being dispensed
*/
@NotNull
public ItemStack getItem() {
return item.clone();
}
@@ -40,7 +42,7 @@ public class BlockDispenseEvent extends BlockEvent implements Cancellable {
*
* @param item the item being dispensed
*/
public void setItem(ItemStack item) {
public void setItem(@NotNull ItemStack item) {
this.item = item;
}
@@ -52,6 +54,7 @@ public class BlockDispenseEvent extends BlockEvent implements Cancellable {
*
* @return A Vector for the dispensed item's velocity
*/
@NotNull
public Vector getVelocity() {
return velocity.clone();
}
@@ -61,7 +64,7 @@ public class BlockDispenseEvent extends BlockEvent implements Cancellable {
*
* @param vel the velocity of the item being dispensed
*/
public void setVelocity(Vector vel) {
public void setVelocity(@NotNull Vector vel) {
velocity = vel;
}
@@ -73,11 +76,13 @@ public class BlockDispenseEvent extends BlockEvent implements Cancellable {
cancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -8,6 +8,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;
/**
* Called if a block broken by a player drops an item.
@@ -36,7 +37,7 @@ public class BlockDropItemEvent extends BlockEvent implements Cancellable {
private final BlockState blockState;
private final List<Item> items;
public BlockDropItemEvent(Block block, BlockState blockState, Player player, List<Item> items) {
public BlockDropItemEvent(@NotNull Block block, @NotNull BlockState blockState, @NotNull Player player, @NotNull List<Item> items) {
super(block);
this.blockState = blockState;
this.player = player;
@@ -48,6 +49,7 @@ public class BlockDropItemEvent extends BlockEvent implements Cancellable {
*
* @return The Player that is breaking the block involved in this event
*/
@NotNull
public Player getPlayer() {
return player;
}
@@ -58,6 +60,7 @@ public class BlockDropItemEvent extends BlockEvent implements Cancellable {
*
* @return The BlockState of the block involved in this event
*/
@NotNull
public BlockState getBlockState() {
return blockState;
}
@@ -70,6 +73,7 @@ public class BlockDropItemEvent extends BlockEvent implements Cancellable {
*
* @return The Item the block caused to drop
*/
@NotNull
public List<Item> getItems() {
return items;
}
@@ -78,6 +82,7 @@ public class BlockDropItemEvent extends BlockEvent implements Cancellable {
* @deprecated very temporary compatibility measure
*/
@Deprecated
@NotNull
public Item getItem() {
return items.get(0);
}
@@ -92,11 +97,13 @@ public class BlockDropItemEvent extends BlockEvent implements Cancellable {
this.cancel = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
/**
* Represents a block related event.
@@ -9,7 +10,7 @@ import org.bukkit.event.Event;
public abstract class BlockEvent extends Event {
protected Block block;
public BlockEvent(final Block theBlock) {
public BlockEvent(@NotNull final Block theBlock) {
block = theBlock;
}
@@ -18,6 +19,7 @@ public abstract class BlockEvent extends Event {
*
* @return The Block which block is involved in this event
*/
@NotNull
public final Block getBlock() {
return block;
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* An event that's called when a block yields experience.
@@ -10,7 +11,7 @@ public class BlockExpEvent extends BlockEvent {
private static final HandlerList handlers = new HandlerList();
private int exp;
public BlockExpEvent(Block block, int exp) {
public BlockExpEvent(@NotNull Block block, int exp) {
super(block);
this.exp = exp;
@@ -35,10 +36,12 @@ public class BlockExpEvent extends BlockEvent {
this.exp = exp;
}
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -15,7 +16,7 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable {
private final List<Block> blocks;
private float yield;
public BlockExplodeEvent(final Block what, final List<Block> blocks, final float yield) {
public BlockExplodeEvent(@NotNull final Block what, @NotNull final List<Block> blocks, final float yield) {
super(what);
this.blocks = blocks;
this.yield = yield;
@@ -36,6 +37,7 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable {
*
* @return All blown-up blocks
*/
@NotNull
public List<Block> blockList() {
return blocks;
}
@@ -58,11 +60,13 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable {
this.yield = yield;
}
@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.block.BlockState;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a block fades, melts or disappears based on world conditions
@@ -25,7 +26,7 @@ public class BlockFadeEvent extends BlockEvent implements Cancellable {
private boolean cancelled;
private final BlockState newState;
public BlockFadeEvent(final Block block, final BlockState newState) {
public BlockFadeEvent(@NotNull final Block block, @NotNull final BlockState newState) {
super(block);
this.newState = newState;
this.cancelled = false;
@@ -38,6 +39,7 @@ public class BlockFadeEvent extends BlockEvent implements Cancellable {
* @return The block state of the block that will be fading, melting or
* disappearing
*/
@NotNull
public BlockState getNewState() {
return newState;
}
@@ -50,11 +52,13 @@ public class BlockFadeEvent extends BlockEvent implements Cancellable {
this.cancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -1,12 +1,15 @@
package org.bukkit.event.block;
import java.util.List;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.world.StructureGrowEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called with the block changes resulting from a player fertilizing a given
@@ -21,7 +24,7 @@ public class BlockFertilizeEvent extends BlockEvent implements Cancellable {
private final Player player;
private final List<BlockState> blocks;
public BlockFertilizeEvent(Block theBlock, Player player, List<BlockState> blocks) {
public BlockFertilizeEvent(@NotNull Block theBlock, @Nullable Player player, @NotNull List<BlockState> blocks) {
super(theBlock);
this.player = player;
this.blocks = blocks;
@@ -32,6 +35,7 @@ public class BlockFertilizeEvent extends BlockEvent implements Cancellable {
*
* @return triggering player, or null if not applicable
*/
@Nullable
public Player getPlayer() {
return player;
}
@@ -41,6 +45,7 @@ public class BlockFertilizeEvent extends BlockEvent implements Cancellable {
*
* @return list of all changed blocks
*/
@NotNull
public List<BlockState> getBlocks() {
return blocks;
}
@@ -55,11 +60,13 @@ public class BlockFertilizeEvent extends BlockEvent implements Cancellable {
this.cancelled = cancelled;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a block is formed or spreads based on world conditions.
@@ -25,15 +26,17 @@ import org.bukkit.event.HandlerList;
public class BlockFormEvent extends BlockGrowEvent {
private static final HandlerList handlers = new HandlerList();
public BlockFormEvent(final Block block, final BlockState newState) {
public BlockFormEvent(@NotNull final Block block, @NotNull final BlockState newState) {
super(block, newState);
}
@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.block.BlockFace;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Represents events with a source block and a destination block, currently
@@ -18,13 +19,13 @@ public class BlockFromToEvent extends BlockEvent implements Cancellable {
protected BlockFace face;
protected boolean cancel;
public BlockFromToEvent(final Block block, final BlockFace face) {
public BlockFromToEvent(@NotNull final Block block, @NotNull final BlockFace face) {
super(block);
this.face = face;
this.cancel = false;
}
public BlockFromToEvent(final Block block, final Block toBlock) {
public BlockFromToEvent(@NotNull final Block block, @NotNull final Block toBlock) {
super(block);
this.to = toBlock;
this.face = BlockFace.SELF;
@@ -36,6 +37,7 @@ public class BlockFromToEvent extends BlockEvent implements Cancellable {
*
* @return The BlockFace that the block is moving to
*/
@NotNull
public BlockFace getFace() {
return face;
}
@@ -45,6 +47,7 @@ public class BlockFromToEvent extends BlockEvent implements Cancellable {
*
* @return The faced Block
*/
@NotNull
public Block getToBlock() {
if (to == null) {
to = block.getRelative(face);
@@ -60,11 +63,13 @@ public class BlockFromToEvent extends BlockEvent 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.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a block grows naturally in the world.
@@ -25,7 +26,7 @@ public class BlockGrowEvent extends BlockEvent implements Cancellable {
private final BlockState newState;
private boolean cancelled = false;
public BlockGrowEvent(final Block block, final BlockState newState) {
public BlockGrowEvent(@NotNull final Block block, @NotNull final BlockState newState) {
super(block);
this.newState = newState;
}
@@ -35,6 +36,7 @@ public class BlockGrowEvent extends BlockEvent implements Cancellable {
*
* @return The block state for this events block
*/
@NotNull
public BlockState getNewState() {
return newState;
}
@@ -47,10 +49,12 @@ public class BlockGrowEvent extends BlockEvent implements Cancellable {
this.cancelled = cancel;
}
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -5,6 +5,8 @@ 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;
import org.jetbrains.annotations.Nullable;
/**
* Called when a block is ignited. If you want to catch when a Player places
@@ -19,15 +21,15 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable {
private final Block ignitingBlock;
private boolean cancel;
public BlockIgniteEvent(final Block theBlock, final IgniteCause cause, final Entity ignitingEntity) {
public BlockIgniteEvent(@NotNull final Block theBlock, @NotNull final IgniteCause cause, @NotNull final Entity ignitingEntity) {
this(theBlock, cause, ignitingEntity, null);
}
public BlockIgniteEvent(final Block theBlock, final IgniteCause cause, final Block ignitingBlock) {
public BlockIgniteEvent(@NotNull final Block theBlock, @NotNull final IgniteCause cause, @NotNull final Block ignitingBlock) {
this(theBlock, cause, null, ignitingBlock);
}
public BlockIgniteEvent(final Block theBlock, final IgniteCause cause, final Entity ignitingEntity, final Block ignitingBlock) {
public BlockIgniteEvent(@NotNull final Block theBlock, @NotNull final IgniteCause cause, @Nullable final Entity ignitingEntity, @Nullable final Block ignitingBlock) {
super(theBlock);
this.cause = cause;
this.ignitingEntity = ignitingEntity;
@@ -48,6 +50,7 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable {
*
* @return An IgniteCause value detailing the cause of block ignition
*/
@NotNull
public IgniteCause getCause() {
return cause;
}
@@ -57,6 +60,7 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable {
*
* @return The Player that placed/ignited the fire block, or null if not ignited by a Player.
*/
@Nullable
public Player getPlayer() {
if (ignitingEntity instanceof Player) {
return (Player) ignitingEntity;
@@ -70,6 +74,7 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable {
*
* @return The Entity that placed/ignited the fire block, or null if not ignited by a Entity.
*/
@Nullable
public Entity getIgnitingEntity() {
return ignitingEntity;
}
@@ -79,6 +84,7 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable {
*
* @return The Block that placed/ignited the fire block, or null if not ignited by a Block.
*/
@Nullable
public Block getIgnitingBlock() {
return ignitingBlock;
}
@@ -118,11 +124,13 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable {
EXPLOSION,
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -5,6 +5,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -18,7 +19,7 @@ import java.util.List;
public class BlockMultiPlaceEvent extends BlockPlaceEvent {
private final List<BlockState> states;
public BlockMultiPlaceEvent(List<BlockState> states, Block clicked, ItemStack itemInHand, Player thePlayer, boolean canBuild) {
public BlockMultiPlaceEvent(@NotNull List<BlockState> states, @NotNull Block clicked, @NotNull ItemStack itemInHand, @NotNull Player thePlayer, boolean canBuild) {
super(states.get(0).getBlock(), states.get(0), clicked, itemInHand, thePlayer, canBuild);
this.states = ImmutableList.copyOf(states);
}
@@ -30,6 +31,7 @@ public class BlockMultiPlaceEvent extends BlockPlaceEvent {
*
* @return immutable list of replaced BlockStates
*/
@NotNull
public List<BlockState> getReplacedBlockStates() {
return states;
}

View File

@@ -5,6 +5,7 @@ import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Thrown when a block physics check is called.
@@ -31,11 +32,11 @@ public class BlockPhysicsEvent extends BlockEvent implements Cancellable {
private final Block sourceBlock;
private boolean cancel = false;
public BlockPhysicsEvent(final Block block, final BlockData changed) {
public BlockPhysicsEvent(@NotNull final Block block, @NotNull final BlockData changed) {
this(block, changed, block);
}
public BlockPhysicsEvent(final Block block, final BlockData changed, final Block sourceBlock) {
public BlockPhysicsEvent(@NotNull final Block block, @NotNull final BlockData changed, @NotNull final Block sourceBlock) {
super(block);
this.changed = changed;
this.sourceBlock = sourceBlock;
@@ -48,6 +49,7 @@ public class BlockPhysicsEvent extends BlockEvent implements Cancellable {
*
* @return The source block
*/
@NotNull
public Block getSourceBlock() {
return sourceBlock;
}
@@ -57,6 +59,7 @@ public class BlockPhysicsEvent extends BlockEvent implements Cancellable {
*
* @return Changed block's type
*/
@NotNull
public Material getChangedType() {
return changed.getMaterial();
}
@@ -69,11 +72,13 @@ public class BlockPhysicsEvent extends BlockEvent 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.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.Cancellable;
import org.jetbrains.annotations.NotNull;
/**
* Called when a piston block is triggered
@@ -12,7 +13,7 @@ public abstract class BlockPistonEvent extends BlockEvent implements Cancellable
private boolean cancelled;
private final BlockFace direction;
public BlockPistonEvent(final Block block, final BlockFace direction) {
public BlockPistonEvent(@NotNull final Block block, @NotNull final BlockFace direction) {
super(block);
this.direction = direction;
}
@@ -39,6 +40,7 @@ public abstract class BlockPistonEvent extends BlockEvent implements Cancellable
*
* @return direction of the piston
*/
@NotNull
public BlockFace getDirection() {
// Both are meh!
// return ((PistonBaseMaterial) block.getType().getNewData(block.getData())).getFacing();

View File

@@ -7,6 +7,7 @@ import java.util.List;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a piston extends
@@ -17,13 +18,13 @@ public class BlockPistonExtendEvent extends BlockPistonEvent {
private List<Block> blocks;
@Deprecated
public BlockPistonExtendEvent(final Block block, final int length, final BlockFace direction) {
public BlockPistonExtendEvent(@NotNull final Block block, final int length, @NotNull final BlockFace direction) {
super(block, direction);
this.length = length;
}
public BlockPistonExtendEvent(final Block block, final List<Block> blocks, final BlockFace direction) {
public BlockPistonExtendEvent(@NotNull final Block block, @NotNull final List<Block> blocks, @NotNull final BlockFace direction) {
super(block, direction);
this.length = blocks.size();
@@ -48,6 +49,7 @@ public class BlockPistonExtendEvent extends BlockPistonEvent {
*
* @return Immutable list of the moved blocks.
*/
@NotNull
public List<Block> getBlocks() {
if (blocks == null) {
ArrayList<Block> tmp = new ArrayList<Block>();
@@ -59,11 +61,13 @@ public class BlockPistonExtendEvent extends BlockPistonEvent {
return blocks;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -5,6 +5,7 @@ import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a piston retracts
@@ -13,7 +14,7 @@ public class BlockPistonRetractEvent extends BlockPistonEvent {
private static final HandlerList handlers = new HandlerList();
private List<Block> blocks;
public BlockPistonRetractEvent(final Block block, final List<Block> blocks, final BlockFace direction) {
public BlockPistonRetractEvent(@NotNull final Block block, @NotNull final List<Block> blocks, @NotNull final BlockFace direction) {
super(block, direction);
this.blocks = blocks;
@@ -26,6 +27,7 @@ public class BlockPistonRetractEvent extends BlockPistonEvent {
* @return The possible location of the possibly moving block.
*/
@Deprecated
@NotNull
public Location getRetractLocation() {
return getBlock().getRelative(getDirection(), 2).getLocation();
}
@@ -36,15 +38,18 @@ public class BlockPistonRetractEvent extends BlockPistonEvent {
*
* @return Immutable list of the moved blocks.
*/
@NotNull
public List<Block> getBlocks() {
return blocks;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -7,6 +7,7 @@ import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* Called when a block is placed by a player.
@@ -24,11 +25,11 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable {
protected EquipmentSlot hand;
@Deprecated
public BlockPlaceEvent(final Block placedBlock, final BlockState replacedBlockState, final Block placedAgainst, final ItemStack itemInHand, final Player thePlayer, final boolean canBuild) {
public BlockPlaceEvent(@NotNull final Block placedBlock, @NotNull final BlockState replacedBlockState, @NotNull final Block placedAgainst, @NotNull final ItemStack itemInHand, @NotNull final Player thePlayer, final boolean canBuild) {
this(placedBlock, replacedBlockState, placedAgainst, itemInHand, thePlayer, canBuild, EquipmentSlot.HAND);
}
public BlockPlaceEvent(final Block placedBlock, final BlockState replacedBlockState, final Block placedAgainst, final ItemStack itemInHand, final Player thePlayer, final boolean canBuild, final EquipmentSlot hand) {
public BlockPlaceEvent(@NotNull final Block placedBlock, @NotNull final BlockState replacedBlockState, @NotNull final Block placedAgainst, @NotNull final ItemStack itemInHand, @NotNull final Player thePlayer, final boolean canBuild, @NotNull final EquipmentSlot hand) {
super(placedBlock);
this.placedAgainst = placedAgainst;
this.itemInHand = itemInHand;
@@ -52,6 +53,7 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable {
*
* @return The Player who placed the block involved in this event
*/
@NotNull
public Player getPlayer() {
return player;
}
@@ -62,6 +64,7 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable {
*
* @return The Block that was placed
*/
@NotNull
public Block getBlockPlaced() {
return getBlock();
}
@@ -72,6 +75,7 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable {
*
* @return The BlockState for the block which was replaced.
*/
@NotNull
public BlockState getBlockReplacedState() {
return this.replacedBlockState;
}
@@ -81,6 +85,7 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable {
*
* @return Block the block that the new block was placed against
*/
@NotNull
public Block getBlockAgainst() {
return placedAgainst;
}
@@ -91,6 +96,7 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable {
* @return The ItemStack for the item in the player's hand when they
* placed the block
*/
@NotNull
public ItemStack getItemInHand() {
return itemInHand;
}
@@ -99,6 +105,7 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable {
* Gets the hand which placed the block
* @return Main or off-hand, depending on which hand was used to place the block
*/
@NotNull
public EquipmentSlot getHand() {
return this.hand;
}
@@ -126,11 +133,13 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable {
this.canBuild = canBuild;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a redstone current changes
@@ -11,7 +12,7 @@ public class BlockRedstoneEvent extends BlockEvent {
private final int oldCurrent;
private int newCurrent;
public BlockRedstoneEvent(final Block block, final int oldCurrent, final int newCurrent) {
public BlockRedstoneEvent(@NotNull final Block block, final int oldCurrent, final int newCurrent) {
super(block);
this.oldCurrent = oldCurrent;
this.newCurrent = newCurrent;
@@ -44,11 +45,13 @@ public class BlockRedstoneEvent extends BlockEvent {
this.newCurrent = newCurrent;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a block spreads based on world conditions.
@@ -24,7 +25,7 @@ public class BlockSpreadEvent extends BlockFormEvent {
private static final HandlerList handlers = new HandlerList();
private final Block source;
public BlockSpreadEvent(final Block block, final Block source, final BlockState newState) {
public BlockSpreadEvent(@NotNull final Block block, @NotNull final Block source, @NotNull final BlockState newState) {
super(block, newState);
this.source = source;
}
@@ -34,15 +35,18 @@ public class BlockSpreadEvent extends BlockFormEvent {
*
* @return the Block for the source block involved in this event.
*/
@NotNull
public Block getSource() {
return source;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -5,6 +5,8 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class CauldronLevelChangeEvent extends BlockEvent implements Cancellable {
@@ -16,7 +18,7 @@ public class CauldronLevelChangeEvent extends BlockEvent implements Cancellable
private final int oldLevel;
private int newLevel;
public CauldronLevelChangeEvent(Block block, Entity entity, ChangeReason reason, int oldLevel, int newLevel) {
public CauldronLevelChangeEvent(@NotNull Block block, @Nullable Entity entity, @NotNull ChangeReason reason, int oldLevel, int newLevel) {
super(block);
this.entity = entity;
this.reason = reason;
@@ -29,10 +31,12 @@ public class CauldronLevelChangeEvent extends BlockEvent implements Cancellable
*
* @return acting entity
*/
@Nullable
public Entity getEntity() {
return entity;
}
@NotNull
public ChangeReason getReason() {
return reason;
}
@@ -60,11 +64,13 @@ public class CauldronLevelChangeEvent extends BlockEvent implements Cancellable
this.cancelled = cancelled;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.jetbrains.annotations.NotNull;
/**
* Called when a block is formed by entities.
@@ -16,7 +17,7 @@ import org.bukkit.entity.Entity;
public class EntityBlockFormEvent extends BlockFormEvent {
private final Entity entity;
public EntityBlockFormEvent(final Entity entity, final Block block, final BlockState blockstate) {
public EntityBlockFormEvent(@NotNull final Entity entity, @NotNull final Block block, @NotNull final BlockState blockstate) {
super(block, blockstate);
this.entity = entity;
@@ -27,6 +28,7 @@ public class EntityBlockFormEvent extends BlockFormEvent {
*
* @return Entity involved in event
*/
@NotNull
public Entity getEntity() {
return entity;
}

View File

@@ -5,6 +5,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when the fluid level of a block changes due to changes in adjacent
@@ -17,7 +18,7 @@ public class FluidLevelChangeEvent extends BlockEvent implements Cancellable {
//
private BlockData newData;
public FluidLevelChangeEvent(Block theBlock, BlockData newData) {
public FluidLevelChangeEvent(@NotNull Block theBlock, @NotNull BlockData newData) {
super(theBlock);
this.newData = newData;
}
@@ -27,6 +28,7 @@ public class FluidLevelChangeEvent extends BlockEvent implements Cancellable {
*
* @return new data
*/
@NotNull
public BlockData getNewData() {
return newData;
}
@@ -37,7 +39,7 @@ public class FluidLevelChangeEvent extends BlockEvent implements Cancellable {
*
* @param newData the new data
*/
public void setNewData(BlockData newData) {
public void setNewData(@NotNull BlockData newData) {
Preconditions.checkArgument(newData != null, "newData null");
Preconditions.checkArgument(this.newData.getMaterial().equals(newData.getMaterial()), "Cannot change fluid type");
@@ -54,11 +56,13 @@ public class FluidLevelChangeEvent extends BlockEvent implements Cancellable {
this.cancelled = cancelled;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when leaves are decaying naturally.
@@ -13,7 +14,7 @@ public class LeavesDecayEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;
public LeavesDecayEvent(final Block block) {
public LeavesDecayEvent(@NotNull final Block block) {
super(block);
}
@@ -25,11 +26,13 @@ public class LeavesDecayEvent extends BlockEvent 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.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when the moisture level of a soil block changes.
@@ -14,7 +15,7 @@ public class MoistureChangeEvent extends BlockEvent implements Cancellable {
private boolean cancelled;
private final BlockState newState;
public MoistureChangeEvent(final Block block, final BlockState newState) {
public MoistureChangeEvent(@NotNull final Block block, @NotNull final BlockState newState) {
super(block);
this.newState = newState;
this.cancelled = false;
@@ -25,6 +26,7 @@ public class MoistureChangeEvent extends BlockEvent implements Cancellable {
*
* @return new block state
*/
@NotNull
public BlockState getNewState() {
return newState;
}
@@ -39,11 +41,13 @@ public class MoistureChangeEvent extends BlockEvent implements Cancellable {
this.cancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -5,6 +5,7 @@ import org.bukkit.Note;
import org.bukkit.block.Block;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a note block is being played through player interaction or a
@@ -17,7 +18,7 @@ public class NotePlayEvent extends BlockEvent implements Cancellable {
private Note note;
private boolean cancelled = false;
public NotePlayEvent(Block block, Instrument instrument, Note note) {
public NotePlayEvent(@NotNull Block block, @NotNull Instrument instrument, @NotNull Note note) {
super(block);
this.instrument = instrument;
this.note = note;
@@ -34,8 +35,9 @@ public class NotePlayEvent extends BlockEvent implements Cancellable {
/**
* Gets the {@link Instrument} to be used.
*
* @return the Instrument;
* @return the Instrument
*/
@NotNull
public Instrument getInstrument() {
return instrument;
}
@@ -43,8 +45,9 @@ public class NotePlayEvent extends BlockEvent implements Cancellable {
/**
* Gets the {@link Note} to be played.
*
* @return the Note.
* @return the Note
*/
@NotNull
public Note getNote() {
return note;
}
@@ -56,11 +59,10 @@ public class NotePlayEvent extends BlockEvent implements Cancellable {
* @deprecated no effect on newer Minecraft versions
*/
@Deprecated
public void setInstrument(Instrument instrument) {
public void setInstrument(@NotNull Instrument instrument) {
if (instrument != null) {
this.instrument = instrument;
}
}
/**
@@ -70,17 +72,19 @@ public class NotePlayEvent extends BlockEvent implements Cancellable {
* @deprecated no effect on newer Minecraft versions
*/
@Deprecated
public void setNote(Note note) {
public void setNote(@NotNull Note note) {
if (note != null) {
this.note = note;
}
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,8 @@ 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;
import org.jetbrains.annotations.Nullable;
/**
* Called when a sign is changed by a player.
@@ -16,7 +18,7 @@ public class SignChangeEvent extends BlockEvent implements Cancellable {
private final Player player;
private final String[] lines;
public SignChangeEvent(final Block theBlock, final Player thePlayer, final String[] theLines) {
public SignChangeEvent(@NotNull final Block theBlock, @NotNull final Player thePlayer, @NotNull final String[] theLines) {
super(theBlock);
this.player = thePlayer;
this.lines = theLines;
@@ -27,6 +29,7 @@ public class SignChangeEvent extends BlockEvent implements Cancellable {
*
* @return the Player involved in this event
*/
@NotNull
public Player getPlayer() {
return player;
}
@@ -36,6 +39,7 @@ public class SignChangeEvent extends BlockEvent implements Cancellable {
*
* @return the String array for the sign's lines new text
*/
@NotNull
public String[] getLines() {
return lines;
}
@@ -49,6 +53,7 @@ public class SignChangeEvent extends BlockEvent implements Cancellable {
* @throws IndexOutOfBoundsException thrown when the provided index is {@literal > 3
* or < 0}
*/
@Nullable
public String getLine(int index) throws IndexOutOfBoundsException {
return lines[index];
}
@@ -61,7 +66,7 @@ public class SignChangeEvent extends BlockEvent implements Cancellable {
* @throws IndexOutOfBoundsException thrown when the provided index is {@literal > 3
* or < 0}
*/
public void setLine(int index, String line) throws IndexOutOfBoundsException {
public void setLine(int index, @Nullable String line) throws IndexOutOfBoundsException {
lines[index] = line;
}
@@ -73,11 +78,13 @@ public class SignChangeEvent extends BlockEvent 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.event.Cancellable;
import org.bukkit.event.HandlerList;
import java.util.List;
import org.bukkit.Material;
import org.jetbrains.annotations.NotNull;
/**
* Called when a sponge absorbs water from the world.
@@ -22,7 +23,7 @@ public class SpongeAbsorbEvent extends BlockEvent implements Cancellable {
private boolean cancelled;
private final List<BlockState> blocks;
public SpongeAbsorbEvent(Block block, List<BlockState> waterblocks) {
public SpongeAbsorbEvent(@NotNull Block block, @NotNull List<BlockState> waterblocks) {
super(block);
this.blocks = waterblocks;
}
@@ -35,6 +36,7 @@ public class SpongeAbsorbEvent extends BlockEvent implements Cancellable {
*
* @return list of the to be removed blocks.
*/
@NotNull
public List<BlockState> getBlocks() {
return blocks;
}
@@ -49,11 +51,13 @@ public class SpongeAbsorbEvent extends BlockEvent implements Cancellable {
this.cancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -11,6 +11,7 @@ import org.bukkit.event.HandlerList;
import org.bukkit.event.inventory.InventoryEvent;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* Called when an ItemStack is successfully enchanted (currently at
@@ -26,7 +27,7 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable {
private final Player enchanter;
private int button;
public EnchantItemEvent(final Player enchanter, final InventoryView view, final Block table, final ItemStack item, final int level, final Map<Enchantment, Integer> enchants, final int i) {
public EnchantItemEvent(@NotNull final Player enchanter, @NotNull final InventoryView view, @NotNull final Block table, @NotNull final ItemStack item, final int level, @NotNull final Map<Enchantment, Integer> enchants, final int i) {
super(view);
this.enchanter = enchanter;
this.table = table;
@@ -42,6 +43,7 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable {
*
* @return enchanting player
*/
@NotNull
public Player getEnchanter() {
return enchanter;
}
@@ -51,6 +53,7 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable {
*
* @return the block used for enchanting
*/
@NotNull
public Block getEnchantBlock() {
return table;
}
@@ -60,6 +63,7 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable {
*
* @return ItemStack of item
*/
@NotNull
public ItemStack getItem() {
return item;
}
@@ -89,6 +93,7 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable {
*
* @return map of enchantment levels, keyed by enchantment
*/
@NotNull
public Map<Enchantment, Integer> getEnchantsToAdd() {
return enchants;
}
@@ -110,11 +115,13 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable {
this.cancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -8,6 +8,7 @@ import org.bukkit.event.HandlerList;
import org.bukkit.event.inventory.InventoryEvent;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* Called when an ItemStack is inserted in an enchantment table - can be
@@ -22,7 +23,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab
private boolean cancelled;
private final Player enchanter;
public PrepareItemEnchantEvent(final Player enchanter, InventoryView view, final Block table, final ItemStack item, final EnchantmentOffer[] offers, final int bonus) {
public PrepareItemEnchantEvent(@NotNull final Player enchanter, @NotNull InventoryView view, @NotNull final Block table, @NotNull final ItemStack item, @NotNull final EnchantmentOffer[] offers, final int bonus) {
super(view);
this.enchanter = enchanter;
this.table = table;
@@ -36,6 +37,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab
*
* @return enchanting player
*/
@NotNull
public Player getEnchanter() {
return enchanter;
}
@@ -45,6 +47,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab
*
* @return the block used for enchanting
*/
@NotNull
public Block getEnchantBlock() {
return table;
}
@@ -54,6 +57,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab
*
* @return ItemStack of item
*/
@NotNull
public ItemStack getItem() {
return item;
}
@@ -64,6 +68,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab
* @return experience level costs offered
* @deprecated Use {@link #getOffers()} instead of this method
*/
@NotNull
public int[] getExpLevelCostsOffered() {
int[] levelOffers = new int[offers.length];
for (int i = 0; i < offers.length; i++) {
@@ -80,6 +85,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab
*
* @return list of available enchantment offers
*/
@NotNull
public EnchantmentOffer[] getOffers() {
return offers;
}
@@ -103,11 +109,13 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab
this.cancelled = 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.AreaEffectCloud;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a lingering potion applies it's effects. Happens
@@ -16,7 +17,7 @@ public class AreaEffectCloudApplyEvent extends EntityEvent implements Cancellabl
private final List<LivingEntity> affectedEntities;
private boolean cancelled = false;
public AreaEffectCloudApplyEvent(final AreaEffectCloud entity, final List<LivingEntity> affectedEntities) {
public AreaEffectCloudApplyEvent(@NotNull final AreaEffectCloud entity, @NotNull final List<LivingEntity> affectedEntities) {
super(entity);
this.affectedEntities = affectedEntities;
}
@@ -32,6 +33,7 @@ public class AreaEffectCloudApplyEvent extends EntityEvent implements Cancellabl
}
@Override
@NotNull
public AreaEffectCloud getEntity() {
return (AreaEffectCloud) entity;
}
@@ -46,15 +48,18 @@ public class AreaEffectCloudApplyEvent extends EntityEvent implements Cancellabl
*
* @return the affected entity list
*/
@NotNull
public List<LivingEntity> getAffectedEntities() {
return affectedEntities;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.entity;
import org.bukkit.entity.Bat;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a bat attempts to sleep or wake up from its slumber.
@@ -17,7 +18,7 @@ public class BatToggleSleepEvent extends EntityEvent implements Cancellable {
private boolean cancel = false;
private final boolean awake;
public BatToggleSleepEvent(Bat what, boolean awake) {
public BatToggleSleepEvent(@NotNull Bat what, boolean awake) {
super(what);
this.awake = awake;
}
@@ -41,11 +42,13 @@ public class BatToggleSleepEvent extends EntityEvent implements Cancellable {
return cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -1,7 +1,7 @@
package org.bukkit.event.entity;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
/**
* Called when a creature is spawned into a world.
@@ -11,11 +11,12 @@ import org.bukkit.entity.LivingEntity;
public class CreatureSpawnEvent extends EntitySpawnEvent {
private final SpawnReason spawnReason;
public CreatureSpawnEvent(final LivingEntity spawnee, final SpawnReason spawnReason) {
public CreatureSpawnEvent(@NotNull final LivingEntity spawnee, @NotNull final SpawnReason spawnReason) {
super(spawnee);
this.spawnReason = spawnReason;
}
@NotNull
@Override
public LivingEntity getEntity() {
return (LivingEntity) entity;
@@ -27,6 +28,7 @@ public class CreatureSpawnEvent extends EntitySpawnEvent {
* @return A SpawnReason value detailing the reason for the creature being
* spawned
*/
@NotNull
public SpawnReason getSpawnReason() {
return spawnReason;
}

View File

@@ -4,6 +4,8 @@ import org.bukkit.entity.Creeper;
import org.bukkit.entity.LightningStrike;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when a Creeper is struck by lightning.
@@ -16,12 +18,12 @@ public class CreeperPowerEvent extends EntityEvent implements Cancellable {
private final PowerCause cause;
private LightningStrike bolt;
public CreeperPowerEvent(final Creeper creeper, final LightningStrike bolt, final PowerCause cause) {
public CreeperPowerEvent(@NotNull final Creeper creeper, @NotNull final LightningStrike bolt, @NotNull final PowerCause cause) {
this(creeper, cause);
this.bolt = bolt;
}
public CreeperPowerEvent(final Creeper creeper, final PowerCause cause) {
public CreeperPowerEvent(@NotNull final Creeper creeper, @NotNull final PowerCause cause) {
super(creeper);
this.cause = cause;
}
@@ -34,6 +36,7 @@ public class CreeperPowerEvent extends EntityEvent implements Cancellable {
canceled = cancel;
}
@NotNull
@Override
public Creeper getEntity() {
return (Creeper) entity;
@@ -44,6 +47,7 @@ public class CreeperPowerEvent extends EntityEvent implements Cancellable {
*
* @return The Entity for the lightning bolt which is striking the Creeper
*/
@Nullable
public LightningStrike getLightning() {
return bolt;
}
@@ -53,15 +57,18 @@ public class CreeperPowerEvent extends EntityEvent implements Cancellable {
*
* @return A PowerCause value detailing the cause of change in power.
*/
@NotNull
public PowerCause getCause() {
return cause;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,8 @@ import org.apache.commons.lang.Validate;
import org.bukkit.entity.EnderDragon;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when an EnderDragon switches controller phase.
@@ -15,12 +17,13 @@ public class EnderDragonChangePhaseEvent extends EntityEvent implements Cancella
private final EnderDragon.Phase currentPhase;
private EnderDragon.Phase newPhase;
public EnderDragonChangePhaseEvent(EnderDragon enderDragon, EnderDragon.Phase currentPhase, EnderDragon.Phase newPhase) {
public EnderDragonChangePhaseEvent(@NotNull EnderDragon enderDragon, @Nullable EnderDragon.Phase currentPhase, @NotNull EnderDragon.Phase newPhase) {
super(enderDragon);
this.currentPhase = currentPhase;
this.setNewPhase(newPhase);
}
@NotNull
@Override
public EnderDragon getEntity() {
return (EnderDragon) entity;
@@ -32,6 +35,7 @@ public class EnderDragonChangePhaseEvent extends EntityEvent implements Cancella
*
* @return the current dragon phase
*/
@Nullable
public EnderDragon.Phase getCurrentPhase() {
return currentPhase;
}
@@ -41,6 +45,7 @@ public class EnderDragonChangePhaseEvent extends EntityEvent implements Cancella
*
* @return the new dragon phase
*/
@NotNull
public EnderDragon.Phase getNewPhase() {
return newPhase;
}
@@ -50,7 +55,7 @@ public class EnderDragonChangePhaseEvent extends EntityEvent implements Cancella
*
* @param newPhase the new dragon phase
*/
public void setNewPhase(EnderDragon.Phase newPhase) {
public void setNewPhase(@NotNull EnderDragon.Phase newPhase) {
Validate.notNull(newPhase, "New dragon phase cannot be null");
this.newPhase = newPhase;
}
@@ -65,11 +70,13 @@ public class EnderDragonChangePhaseEvent extends EntityEvent implements Cancella
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.entity;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when the amount of air an entity has remaining changes.
@@ -15,7 +16,7 @@ public class EntityAirChangeEvent extends EntityEvent implements Cancellable {
//
private boolean cancelled;
public EntityAirChangeEvent(Entity what, int amount) {
public EntityAirChangeEvent(@NotNull Entity what, int amount) {
super(what);
this.amount = amount;
}
@@ -48,11 +49,13 @@ public class EntityAirChangeEvent extends EntityEvent implements Cancellable {
this.cancelled = cancelled;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
/**
* Called when an {@link Entity} breaks a door
@@ -11,10 +12,11 @@ import org.bukkit.entity.LivingEntity;
* Cancelling the event will cause the event to be delayed
*/
public class EntityBreakDoorEvent extends EntityChangeBlockEvent {
public EntityBreakDoorEvent(final LivingEntity entity, final Block targetBlock) {
public EntityBreakDoorEvent(@NotNull final LivingEntity entity, @NotNull final Block targetBlock) {
super(entity, targetBlock, Material.AIR.createBlockData());
}
@NotNull
@Override
public LivingEntity getEntity() {
return (LivingEntity) entity;

View File

@@ -5,6 +5,8 @@ import org.bukkit.entity.LivingEntity;
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 one Entity breeds with another Entity.
@@ -21,7 +23,7 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable {
//
private boolean cancel;
public EntityBreedEvent(LivingEntity child, LivingEntity mother, LivingEntity father, LivingEntity breeder, ItemStack bredWith, int experience) {
public EntityBreedEvent(@NotNull LivingEntity child, @NotNull LivingEntity mother, @NotNull LivingEntity father, @Nullable LivingEntity breeder, @Nullable ItemStack bredWith, int experience) {
super(child);
Validate.notNull(child, "Cannot have null child");
@@ -37,6 +39,7 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable {
setExperience(experience);
}
@NotNull
@Override
public LivingEntity getEntity() {
return (LivingEntity) entity;
@@ -47,6 +50,7 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable {
*
* @return The "birth" parent
*/
@NotNull
public LivingEntity getMother() {
return mother;
}
@@ -56,6 +60,7 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable {
*
* @return the other parent
*/
@NotNull
public LivingEntity getFather() {
return father;
}
@@ -66,6 +71,7 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable {
*
* @return The Entity who initiated breeding.
*/
@Nullable
public LivingEntity getBreeder() {
return breeder;
}
@@ -75,6 +81,7 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable {
*
* @return ItemStack used to initiate breeding.
*/
@Nullable
public ItemStack getBredWith() {
return bredWith;
}
@@ -108,11 +115,13 @@ public class EntityBreedEvent extends EntityEvent 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.block.data.BlockData;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when any Entity, excluding players, changes a block.
@@ -16,7 +17,7 @@ public class EntityChangeBlockEvent extends EntityEvent implements Cancellable {
private boolean cancel;
private final BlockData to;
public EntityChangeBlockEvent(final Entity what, final Block block, final BlockData to) {
public EntityChangeBlockEvent(@NotNull final Entity what, @NotNull final Block block, @NotNull final BlockData to) {
super(what);
this.block = block;
this.cancel = false;
@@ -28,6 +29,7 @@ public class EntityChangeBlockEvent extends EntityEvent implements Cancellable {
*
* @return the block that is changing
*/
@NotNull
public Block getBlock() {
return block;
}
@@ -45,6 +47,7 @@ public class EntityChangeBlockEvent extends EntityEvent implements Cancellable {
*
* @return the material that the block is changing into
*/
@NotNull
public Material getTo() {
return to.getMaterial();
}
@@ -54,15 +57,18 @@ public class EntityChangeBlockEvent extends EntityEvent implements Cancellable {
*
* @return the data for the block that would be changed into
*/
@NotNull
public BlockData getBlockData() {
return to;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -2,6 +2,8 @@ package org.bukkit.event.entity;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when a block causes an entity to combust.
@@ -9,7 +11,7 @@ import org.bukkit.entity.Entity;
public class EntityCombustByBlockEvent extends EntityCombustEvent {
private final Block combuster;
public EntityCombustByBlockEvent(final Block combuster, final Entity combustee, final int duration) {
public EntityCombustByBlockEvent(@Nullable final Block combuster, @NotNull final Entity combustee, final int duration) {
super(combustee, duration);
this.combuster = combuster;
}
@@ -21,6 +23,7 @@ public class EntityCombustByBlockEvent extends EntityCombustEvent {
*
* @return the Block that set the combustee alight.
*/
@Nullable
public Block getCombuster() {
return combuster;
}

View File

@@ -1,6 +1,7 @@
package org.bukkit.event.entity;
import org.bukkit.entity.Entity;
import org.jetbrains.annotations.NotNull;
/**
* Called when an entity causes another entity to combust.
@@ -8,7 +9,7 @@ import org.bukkit.entity.Entity;
public class EntityCombustByEntityEvent extends EntityCombustEvent {
private final Entity combuster;
public EntityCombustByEntityEvent(final Entity combuster, final Entity combustee, final int duration) {
public EntityCombustByEntityEvent(@NotNull final Entity combuster, @NotNull final Entity combustee, final int duration) {
super(combustee, duration);
this.combuster = combuster;
}
@@ -18,6 +19,7 @@ public class EntityCombustByEntityEvent extends EntityCombustEvent {
*
* @return the Entity that set the combustee alight.
*/
@NotNull
public Entity getCombuster() {
return combuster;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.entity;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when an entity combusts.
@@ -14,7 +15,7 @@ public class EntityCombustEvent extends EntityEvent implements Cancellable {
private int duration;
private boolean cancel;
public EntityCombustEvent(final Entity combustee, final int duration) {
public EntityCombustEvent(@NotNull final Entity combustee, final int duration) {
super(combustee);
this.duration = duration;
this.cancel = false;
@@ -48,11 +49,13 @@ public class EntityCombustEvent extends EntityEvent implements Cancellable {
this.duration = duration;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -6,6 +6,7 @@ import org.bukkit.block.BlockState;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Thrown when a Living Entity creates a portal in a world.
@@ -16,13 +17,14 @@ public class EntityCreatePortalEvent extends EntityEvent implements Cancellable
private boolean cancelled = false;
private PortalType type = PortalType.CUSTOM;
public EntityCreatePortalEvent(final LivingEntity what, final List<BlockState> blocks, final PortalType type) {
public EntityCreatePortalEvent(@NotNull final LivingEntity what, @NotNull final List<BlockState> blocks, @NotNull final PortalType type) {
super(what);
this.blocks = blocks;
this.type = type;
}
@NotNull
@Override
public LivingEntity getEntity() {
return (LivingEntity) entity;
@@ -33,6 +35,7 @@ public class EntityCreatePortalEvent extends EntityEvent implements Cancellable
*
* @return List of blocks that will be changed.
*/
@NotNull
public List<BlockState> getBlocks() {
return blocks;
}
@@ -50,15 +53,18 @@ public class EntityCreatePortalEvent extends EntityEvent implements Cancellable
*
* @return Type of portal.
*/
@NotNull
public PortalType getPortalType() {
return type;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -5,6 +5,8 @@ import java.util.Map;
import com.google.common.base.Function;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when an entity is damaged by a block
@@ -12,12 +14,12 @@ import org.bukkit.entity.Entity;
public class EntityDamageByBlockEvent extends EntityDamageEvent {
private final Block damager;
public EntityDamageByBlockEvent(final Block damager, final Entity damagee, final DamageCause cause, final double damage) {
public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) {
super(damagee, cause, damage);
this.damager = damager;
}
public EntityDamageByBlockEvent(final Block damager, final Entity damagee, final DamageCause cause, final Map<DamageModifier, Double> modifiers, final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
super(damagee, cause, modifiers, modifierFunctions);
this.damager = damager;
}
@@ -27,6 +29,7 @@ public class EntityDamageByBlockEvent extends EntityDamageEvent {
*
* @return Block that damaged the player
*/
@Nullable
public Block getDamager() {
return damager;
}

View File

@@ -4,6 +4,7 @@ import java.util.Map;
import com.google.common.base.Function;
import org.bukkit.entity.Entity;
import org.jetbrains.annotations.NotNull;
/**
* Called when an entity is damaged by an entity
@@ -11,12 +12,12 @@ import org.bukkit.entity.Entity;
public class EntityDamageByEntityEvent extends EntityDamageEvent {
private final Entity damager;
public EntityDamageByEntityEvent(final Entity damager, final Entity damagee, final DamageCause cause, final double damage) {
public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) {
super(damagee, cause, damage);
this.damager = damager;
}
public EntityDamageByEntityEvent(final Entity damager, final Entity damagee, final DamageCause cause, final Map<DamageModifier, Double> modifiers, final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
super(damagee, cause, modifiers, modifierFunctions);
this.damager = damager;
}
@@ -26,6 +27,7 @@ public class EntityDamageByEntityEvent extends EntityDamageEvent {
*
* @return Entity that damaged the defender.
*/
@NotNull
public Entity getDamager() {
return damager;
}

View File

@@ -13,6 +13,7 @@ import org.bukkit.event.HandlerList;
import com.google.common.base.Function;
import com.google.common.base.Functions;
import com.google.common.collect.ImmutableMap;
import org.jetbrains.annotations.NotNull;
/**
* Stores data for damage events
@@ -27,11 +28,11 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
private boolean cancelled;
private final DamageCause cause;
public EntityDamageEvent(final Entity damagee, final DamageCause cause, final double damage) {
public EntityDamageEvent(@NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) {
this(damagee, cause, new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, damage)), new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, ZERO)));
}
public EntityDamageEvent(final Entity damagee, final DamageCause cause, final Map<DamageModifier, Double> modifiers, final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
public EntityDamageEvent(@NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
super(damagee);
Validate.isTrue(modifiers.containsKey(DamageModifier.BASE), "BASE DamageModifier missing");
Validate.isTrue(!modifiers.containsKey(null), "Cannot have null DamageModifier");
@@ -60,7 +61,7 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
* @return the original damage
* @throws IllegalArgumentException if type is null
*/
public double getOriginalDamage(DamageModifier type) throws IllegalArgumentException {
public double getOriginalDamage(@NotNull DamageModifier type) throws IllegalArgumentException {
final Double damage = originals.get(type);
if (damage != null) {
return damage;
@@ -82,7 +83,7 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
* the particular DamageModifier, or to rephrase, when {@link
* #isApplicable(DamageModifier)} returns false
*/
public void setDamage(DamageModifier type, double damage) throws IllegalArgumentException, UnsupportedOperationException {
public void setDamage(@NotNull DamageModifier type, double damage) throws IllegalArgumentException, UnsupportedOperationException {
if (!modifiers.containsKey(type)) {
throw type == null ? new IllegalArgumentException("Cannot have null DamageModifier") : new UnsupportedOperationException(type + " is not applicable to " + getEntity());
}
@@ -97,7 +98,7 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
* @throws IllegalArgumentException if type is null
* @see DamageModifier#BASE
*/
public double getDamage(DamageModifier type) throws IllegalArgumentException {
public double getDamage(@NotNull DamageModifier type) throws IllegalArgumentException {
Validate.notNull(type, "Cannot have null DamageModifier");
final Double damage = modifiers.get(type);
return damage == null ? 0 : damage;
@@ -114,7 +115,7 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
* @return true if the modifier is supported by the caller, false otherwise
* @throws IllegalArgumentException if type is null
*/
public boolean isApplicable(DamageModifier type) throws IllegalArgumentException {
public boolean isApplicable(@NotNull DamageModifier type) throws IllegalArgumentException {
Validate.notNull(type, "Cannot have null DamageModifier");
return modifiers.containsKey(type);
}
@@ -185,15 +186,18 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
*
* @return A DamageCause value detailing the cause of the damage.
*/
@NotNull
public DamageCause getCause() {
return cause;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,7 @@ import java.util.List;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* Thrown whenever a LivingEntity dies
@@ -13,16 +14,17 @@ public class EntityDeathEvent extends EntityEvent {
private final List<ItemStack> drops;
private int dropExp = 0;
public EntityDeathEvent(final LivingEntity entity, final List<ItemStack> drops) {
public EntityDeathEvent(@NotNull final LivingEntity entity, @NotNull final List<ItemStack> drops) {
this(entity, drops, 0);
}
public EntityDeathEvent(final LivingEntity what, final List<ItemStack> drops, final int droppedExp) {
public EntityDeathEvent(@NotNull final LivingEntity what, @NotNull final List<ItemStack> drops, final int droppedExp) {
super(what);
this.drops = drops;
this.dropExp = droppedExp;
}
@NotNull
@Override
public LivingEntity getEntity() {
return (LivingEntity) entity;
@@ -57,15 +59,18 @@ public class EntityDeathEvent extends EntityEvent {
*
* @return Items to drop when the entity dies
*/
@NotNull
public List<ItemStack> getDrops() {
return drops;
}
@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.Item;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Thrown when an entity creates an item drop.
@@ -14,7 +15,7 @@ public class EntityDropItemEvent extends EntityEvent implements Cancellable {
private final Item drop;
private boolean cancel = false;
public EntityDropItemEvent(final Entity entity, final Item drop) {
public EntityDropItemEvent(@NotNull final Entity entity, @NotNull final Item drop) {
super(entity);
this.drop = drop;
}
@@ -24,6 +25,7 @@ public class EntityDropItemEvent extends EntityEvent implements Cancellable {
*
* @return Item created by the entity
*/
@NotNull
public Item getItemDrop() {
return drop;
}
@@ -38,11 +40,13 @@ public class EntityDropItemEvent extends EntityEvent 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.entity;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
/**
* Represents an Entity-related event
@@ -10,7 +11,7 @@ import org.bukkit.event.Event;
public abstract class EntityEvent extends Event {
protected Entity entity;
public EntityEvent(final Entity what) {
public EntityEvent(@NotNull final Entity what) {
entity = what;
}
@@ -19,6 +20,7 @@ public abstract class EntityEvent extends Event {
*
* @return Entity who is involved in this event
*/
@NotNull
public Entity getEntity() {
return entity;
}
@@ -28,6 +30,7 @@ public abstract class EntityEvent extends Event {
*
* @return EntityType of the Entity involved in this event
*/
@NotNull
public EntityType getEntityType() {
return entity.getType();
}

View File

@@ -5,6 +5,8 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@@ -18,7 +20,7 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable {
private final List<Block> blocks;
private float yield;
public EntityExplodeEvent(final Entity what, final Location location, final List<Block> blocks, final float yield) {
public EntityExplodeEvent(@NotNull final Entity what, @NotNull final Location location, @NotNull final List<Block> blocks, final float yield) {
super(what);
this.location = location;
this.blocks = blocks;
@@ -40,6 +42,7 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable {
*
* @return All blown-up blocks
*/
@NotNull
public List<Block> blockList() {
return blocks;
}
@@ -52,6 +55,7 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable {
*
* @return The location of the explosion
*/
@NotNull
public Location getLocation() {
return location;
}
@@ -74,11 +78,13 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable {
this.yield = yield;
}
@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.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when an entity interacts with an object
@@ -13,7 +14,7 @@ public class EntityInteractEvent extends EntityEvent implements Cancellable {
protected Block block;
private boolean cancelled;
public EntityInteractEvent(final Entity entity, final Block block) {
public EntityInteractEvent(@NotNull final Entity entity, @NotNull final Block block) {
super(entity);
this.block = block;
}
@@ -31,15 +32,18 @@ public class EntityInteractEvent extends EntityEvent implements Cancellable {
*
* @return the block clicked with this item.
*/
@NotNull
public Block getBlock() {
return block;
}
@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.LivingEntity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Thrown when a entity picks an item up from the ground
@@ -14,12 +15,13 @@ public class EntityPickupItemEvent extends EntityEvent implements Cancellable {
private boolean cancel = false;
private final int remaining;
public EntityPickupItemEvent(final LivingEntity entity, final Item item, final int remaining) {
public EntityPickupItemEvent(@NotNull final LivingEntity entity, @NotNull final Item item, final int remaining) {
super(entity);
this.item = item;
this.remaining = remaining;
}
@NotNull
@Override
public LivingEntity getEntity() {
return (LivingEntity) entity;
@@ -30,6 +32,7 @@ public class EntityPickupItemEvent extends EntityEvent implements Cancellable {
*
* @return Item
*/
@NotNull
public Item getItem() {
return item;
}
@@ -51,11 +54,13 @@ public class EntityPickupItemEvent extends EntityEvent implements Cancellable {
this.cancel = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -7,6 +7,8 @@ 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;
import org.jetbrains.annotations.Nullable;
/**
* Triggered when a entity is created in the world by a player "placing" an item
@@ -27,7 +29,7 @@ public class EntityPlaceEvent extends EntityEvent implements Cancellable {
private final Block block;
private final BlockFace blockFace;
public EntityPlaceEvent(final Entity entity, final Player player, final Block block, final BlockFace blockFace) {
public EntityPlaceEvent(@NotNull final Entity entity, @Nullable final Player player, @NotNull final Block block, @NotNull final BlockFace blockFace) {
super(entity);
this.player = player;
this.block = block;
@@ -39,6 +41,7 @@ public class EntityPlaceEvent extends EntityEvent implements Cancellable {
*
* @return the player placing the entity
*/
@Nullable
public Player getPlayer() {
return player;
}
@@ -48,6 +51,7 @@ public class EntityPlaceEvent extends EntityEvent implements Cancellable {
*
* @return the block that the entity was placed on
*/
@NotNull
public Block getBlock() {
return block;
}
@@ -57,6 +61,7 @@ public class EntityPlaceEvent extends EntityEvent implements Cancellable {
*
* @return the face of the block that the entity was placed on
*/
@NotNull
public BlockFace getBlockFace() {
return blockFace;
}
@@ -71,11 +76,13 @@ public class EntityPlaceEvent extends EntityEvent 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.entity;
import org.bukkit.entity.Entity;
import org.bukkit.Location;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when an entity comes into contact with a portal
@@ -11,7 +12,7 @@ public class EntityPortalEnterEvent extends EntityEvent {
private static final HandlerList handlers = new HandlerList();
private final Location location;
public EntityPortalEnterEvent(final Entity entity, final Location location) {
public EntityPortalEnterEvent(@NotNull final Entity entity, @NotNull final Location location) {
super(entity);
this.location = location;
}
@@ -21,15 +22,18 @@ public class EntityPortalEnterEvent extends EntityEvent {
*
* @return The portal block the entity is touching
*/
@NotNull
public Location getLocation() {
return location;
}
@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.Entity;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when a non-player entity is about to teleport because it is in
@@ -16,7 +18,7 @@ public class EntityPortalEvent extends EntityTeleportEvent {
protected boolean useTravelAgent = true;
protected TravelAgent travelAgent;
public EntityPortalEvent(final Entity entity, final Location from, final Location to, final TravelAgent pta) {
public EntityPortalEvent(@NotNull final Entity entity, @NotNull final Location from, @Nullable final Location to, @NotNull final TravelAgent pta) {
super(entity, from, to);
this.travelAgent = pta;
}
@@ -58,6 +60,7 @@ public class EntityPortalEvent extends EntityTeleportEvent {
*
* @return the Travel Agent used (or not) in this event
*/
@NotNull
public TravelAgent getPortalTravelAgent() {
return this.travelAgent;
}
@@ -67,15 +70,17 @@ public class EntityPortalEvent extends EntityTeleportEvent {
*
* @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

@@ -4,6 +4,7 @@ import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.event.HandlerList;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
/**
* Called before an entity exits a portal.
@@ -16,7 +17,7 @@ public class EntityPortalExitEvent extends EntityTeleportEvent {
private Vector before;
private Vector after;
public EntityPortalExitEvent(final Entity entity, final Location from, final Location to, final Vector before, final Vector after) {
public EntityPortalExitEvent(@NotNull final Entity entity, @NotNull final Location from, @NotNull final Location to, @NotNull final Vector before, @NotNull final Vector after) {
super(entity, from, to);
this.before = before;
this.after = after;
@@ -28,6 +29,7 @@ public class EntityPortalExitEvent extends EntityTeleportEvent {
*
* @return velocity of entity before entering the portal
*/
@NotNull
public Vector getBefore() {
return this.before.clone();
}
@@ -38,6 +40,7 @@ public class EntityPortalExitEvent extends EntityTeleportEvent {
*
* @return velocity of entity after exiting the portal
*/
@NotNull
public Vector getAfter() {
return this.after.clone();
}
@@ -47,15 +50,17 @@ public class EntityPortalExitEvent extends EntityTeleportEvent {
*
* @param after the velocity after exiting the portal
*/
public void setAfter(Vector after) {
public void setAfter(@NotNull Vector after) {
this.after = after.clone();
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -5,6 +5,9 @@ import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when a potion effect is modified on an entity.
@@ -21,7 +24,8 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable
private final Action action;
private boolean override;
public EntityPotionEffectEvent(LivingEntity livingEntity, PotionEffect oldEffect, PotionEffect newEffect, Cause cause, Action action, boolean override) {
@Contract("_, null, null, _, _, _ -> fail")
public EntityPotionEffectEvent(@NotNull LivingEntity livingEntity, @Nullable PotionEffect oldEffect, @Nullable PotionEffect newEffect, @NotNull Cause cause, @NotNull Action action, boolean override) {
super(livingEntity);
this.oldEffect = oldEffect;
this.newEffect = newEffect;
@@ -36,6 +40,7 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable
* @return The old potion effect or null if the entity did not have the
* changed effect type.
*/
@Nullable
public PotionEffect getOldEffect() {
return oldEffect;
}
@@ -46,6 +51,7 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable
* @return The new potion effect or null if the effect of the changed type
* will be removed.
*/
@Nullable
public PotionEffect getNewEffect() {
return newEffect;
}
@@ -55,6 +61,7 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable
*
* @return A Cause value why the effect has changed.
*/
@NotNull
public Cause getCause() {
return cause;
}
@@ -64,6 +71,7 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable
*
* @return An action to be performed on the potion effect type.
*/
@NotNull
public Action getAction() {
return action;
}
@@ -73,6 +81,7 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable
*
* @return The effect type which will be modified on the entity.
*/
@NotNull
public PotionEffectType getModifiedType() {
return (oldEffect == null) ? ((newEffect == null) ? null : newEffect.getType()) : oldEffect.getType();
}
@@ -107,11 +116,13 @@ public class EntityPotionEffectEvent extends EntityEvent 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.entity;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Stores data for health-regain events
@@ -13,7 +14,7 @@ public class EntityRegainHealthEvent extends EntityEvent implements Cancellable
private double amount;
private final RegainReason regainReason;
public EntityRegainHealthEvent(final Entity entity, final double amount, final RegainReason regainReason) {
public EntityRegainHealthEvent(@NotNull final Entity entity, final double amount, @NotNull final RegainReason regainReason) {
super(entity);
this.amount = amount;
this.regainReason = regainReason;
@@ -53,15 +54,18 @@ public class EntityRegainHealthEvent extends EntityEvent implements Cancellable
* @return A RegainReason detailing the reason for the entity regaining
* health
*/
@NotNull
public RegainReason getRegainReason() {
return regainReason;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when an entity dies and may have the opportunity to be resurrected.
@@ -15,10 +16,11 @@ public class EntityResurrectEvent extends EntityEvent implements Cancellable {
//
private boolean cancelled;
public EntityResurrectEvent(LivingEntity what) {
public EntityResurrectEvent(@NotNull LivingEntity what) {
super(what);
}
@NotNull
@Override
public LivingEntity getEntity() {
return (LivingEntity) entity;
@@ -34,11 +36,13 @@ public class EntityResurrectEvent extends EntityEvent implements Cancellable {
this.cancelled = cancelled;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -6,6 +6,8 @@ import org.bukkit.entity.Projectile;
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 LivingEntity shoots a bow firing an arrow
@@ -17,13 +19,14 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable {
private final float force;
private boolean cancelled;
public EntityShootBowEvent(final LivingEntity shooter, final ItemStack bow, final Projectile projectile, final float force) {
public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @NotNull final Projectile projectile, final float force) {
super(shooter);
this.bow = bow;
this.projectile = projectile;
this.force = force;
}
@NotNull
@Override
public LivingEntity getEntity() {
return (LivingEntity) entity;
@@ -34,6 +37,7 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable {
*
* @return the bow involved in this event
*/
@Nullable
public ItemStack getBow() {
return bow;
}
@@ -43,6 +47,7 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable {
*
* @return the launched projectile
*/
@NotNull
public Entity getProjectile() {
return projectile;
}
@@ -52,7 +57,7 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable {
*
* @param projectile the new projectile
*/
public void setProjectile(Entity projectile) {
public void setProjectile(@NotNull Entity projectile) {
this.projectile = projectile;
}
@@ -73,11 +78,13 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable {
cancelled = cancel;
}
@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.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when an entity is spawned into a world.
@@ -15,7 +16,7 @@ public class EntitySpawnEvent extends EntityEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean canceled;
public EntitySpawnEvent(final Entity spawnee) {
public EntitySpawnEvent(@NotNull final Entity spawnee) {
super(spawnee);
}
@@ -34,15 +35,18 @@ public class EntitySpawnEvent extends EntityEvent implements Cancellable {
*
* @return The location at which the entity is spawning
*/
@NotNull
public Location getLocation() {
return getEntity().getLocation();
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Thrown when a LivingEntity is tamed
@@ -13,11 +14,12 @@ public class EntityTameEvent extends EntityEvent implements Cancellable {
private boolean cancelled;
private final AnimalTamer owner;
public EntityTameEvent(final LivingEntity entity, final AnimalTamer owner) {
public EntityTameEvent(@NotNull final LivingEntity entity, @NotNull final AnimalTamer owner) {
super(entity);
this.owner = owner;
}
@NotNull
@Override
public LivingEntity getEntity() {
return (LivingEntity) entity;
@@ -36,15 +38,18 @@ public class EntityTameEvent extends EntityEvent implements Cancellable {
*
* @return the owning AnimalTamer
*/
@NotNull
public AnimalTamer getOwner() {
return owner;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,8 @@ package org.bukkit.event.entity;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when a creature targets or untargets another entity
@@ -13,7 +15,7 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable {
private Entity target;
private final TargetReason reason;
public EntityTargetEvent(final Entity entity, final Entity target, final TargetReason reason) {
public EntityTargetEvent(@NotNull final Entity entity, @Nullable final Entity target, @NotNull final TargetReason reason) {
super(entity);
this.target = target;
this.reason = reason;
@@ -32,6 +34,7 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable {
*
* @return The reason
*/
@NotNull
public TargetReason getReason() {
return reason;
}
@@ -44,6 +47,7 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable {
*
* @return The entity
*/
@Nullable
public Entity getTarget() {
return target;
}
@@ -60,15 +64,17 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable {
*
* @param target The entity to target
*/
public void setTarget(Entity target) {
public void setTarget(@Nullable Entity target) {
this.target = target;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -2,16 +2,19 @@ package org.bukkit.event.entity;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when an Entity targets a {@link LivingEntity} and can only target
* LivingEntity's.
*/
public class EntityTargetLivingEntityEvent extends EntityTargetEvent{
public EntityTargetLivingEntityEvent(final Entity entity, final LivingEntity target, final TargetReason reason) {
public EntityTargetLivingEntityEvent(@NotNull final Entity entity, @Nullable final LivingEntity target, @Nullable final TargetReason reason) {
super(entity, target, reason);
}
@Nullable
public LivingEntity getTarget() {
return (LivingEntity) super.getTarget();
}
@@ -26,7 +29,7 @@ public class EntityTargetLivingEntityEvent extends EntityTargetEvent{
*
* @param target The entity to target
*/
public void setTarget(Entity target) {
public void setTarget(@Nullable Entity target) {
if (target == null || target instanceof LivingEntity) {
super.setTarget(target);
}

View File

@@ -4,6 +4,8 @@ import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Thrown when a non-player entity is teleported from one location to another.
@@ -17,7 +19,7 @@ public class EntityTeleportEvent extends EntityEvent implements Cancellable {
private Location from;
private Location to;
public EntityTeleportEvent(Entity what, Location from, Location to) {
public EntityTeleportEvent(@NotNull Entity what, @NotNull Location from, @Nullable Location to) {
super(what);
this.from = from;
this.to = to;
@@ -37,6 +39,7 @@ public class EntityTeleportEvent extends EntityEvent implements Cancellable {
*
* @return Location this entity moved from
*/
@NotNull
public Location getFrom() {
return from;
}
@@ -46,7 +49,7 @@ public class EntityTeleportEvent extends EntityEvent implements Cancellable {
*
* @param from New location this entity moved from
*/
public void setFrom(Location from) {
public void setFrom(@NotNull Location from) {
this.from = from;
}
@@ -55,6 +58,7 @@ public class EntityTeleportEvent extends EntityEvent implements Cancellable {
*
* @return Location the entity moved to
*/
@Nullable
public Location getTo() {
return to;
}
@@ -64,15 +68,17 @@ public class EntityTeleportEvent extends EntityEvent implements Cancellable {
*
* @param to New Location this entity moved to
*/
public void setTo(Location to) {
public void setTo(@Nullable Location to) {
this.to = to;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Sent when an entity's gliding status is toggled with an Elytra.
@@ -19,7 +20,7 @@ public class EntityToggleGlideEvent extends EntityEvent implements Cancellable {
private boolean cancel = false;
private final boolean isGliding;
public EntityToggleGlideEvent(LivingEntity who, final boolean isGliding) {
public EntityToggleGlideEvent(@NotNull LivingEntity who, final boolean isGliding) {
super(who);
this.isGliding = isGliding;
}
@@ -38,11 +39,13 @@ public class EntityToggleGlideEvent extends EntityEvent implements Cancellable {
return isGliding;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Sent when an entity's swimming status is toggled.
@@ -13,7 +14,7 @@ public class EntityToggleSwimEvent extends EntityEvent implements Cancellable {
private boolean cancel = false;
private final boolean isSwimming;
public EntityToggleSwimEvent(LivingEntity who, final boolean isSwimming) {
public EntityToggleSwimEvent(@NotNull LivingEntity who, final boolean isSwimming) {
super(who);
this.isSwimming = isSwimming;
}
@@ -32,11 +33,13 @@ public class EntityToggleSwimEvent extends EntityEvent implements Cancellable {
return isSwimming;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -5,6 +5,7 @@ import java.util.List;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when an entity is about to be replaced by another entity.
@@ -17,7 +18,7 @@ public class EntityTransformEvent extends EntityEvent implements Cancellable {
private final List<Entity> convertedList;
private final TransformReason transformReason;
public EntityTransformEvent(Entity original, List<Entity> convertedList, TransformReason transformReason) {
public EntityTransformEvent(@NotNull Entity original, @NotNull List<Entity> convertedList, @NotNull TransformReason transformReason) {
super(original);
this.convertedList = Collections.unmodifiableList(convertedList);
this.converted = convertedList.get(0);
@@ -32,6 +33,7 @@ public class EntityTransformEvent extends EntityEvent implements Cancellable {
* @return The transformed entity.
* @see #getTransformedEntities()
*/
@NotNull
public Entity getTransformedEntity() {
return converted;
}
@@ -41,6 +43,7 @@ public class EntityTransformEvent extends EntityEvent implements Cancellable {
*
* @return The transformed entities.
*/
@NotNull
public List<Entity> getTransformedEntities() {
return convertedList;
}
@@ -50,6 +53,7 @@ public class EntityTransformEvent extends EntityEvent implements Cancellable {
*
* @return The reason for conversion that has occurred.
*/
@NotNull
public TransformReason getTransformReason() {
return transformReason;
}
@@ -64,11 +68,13 @@ public class EntityTransformEvent extends EntityEvent implements Cancellable {
cancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.entity;
import org.bukkit.entity.Entity;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called immediately prior to an entity being unleashed.
@@ -10,7 +11,7 @@ public class EntityUnleashEvent extends EntityEvent {
private static final HandlerList handlers = new HandlerList();
private final UnleashReason reason;
public EntityUnleashEvent(Entity entity, UnleashReason reason) {
public EntityUnleashEvent(@NotNull Entity entity, @NotNull UnleashReason reason) {
super(entity);
this.reason = reason;
}
@@ -20,15 +21,18 @@ public class EntityUnleashEvent extends EntityEvent {
*
* @return The reason
*/
@NotNull
public UnleashReason getReason() {
return reason;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.entity;
import org.bukkit.entity.ThrownExpBottle;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a ThrownExpBottle hits and releases experience.
@@ -11,11 +12,12 @@ public class ExpBottleEvent extends ProjectileHitEvent {
private int exp;
private boolean showEffect = true;
public ExpBottleEvent(final ThrownExpBottle bottle, final int exp) {
public ExpBottleEvent(@NotNull final ThrownExpBottle bottle, final int exp) {
super(bottle);
this.exp = exp;
}
@NotNull
@Override
public ThrownExpBottle getEntity() {
return (ThrownExpBottle) entity;
@@ -64,11 +66,13 @@ public class ExpBottleEvent extends ProjectileHitEvent {
this.exp = exp;
}
@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.Explosive;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when an entity has made a decision to explode.
@@ -14,14 +15,14 @@ public class ExplosionPrimeEvent extends EntityEvent implements Cancellable {
private float radius;
private boolean fire;
public ExplosionPrimeEvent(final Entity what, final float radius, final boolean fire) {
public ExplosionPrimeEvent(@NotNull final Entity what, final float radius, final boolean fire) {
super(what);
this.cancel = false;
this.radius = radius;
this.fire = fire;
}
public ExplosionPrimeEvent(final Explosive explosive) {
public ExplosionPrimeEvent(@NotNull final Explosive explosive) {
this(explosive, explosive.getYield(), explosive.isIncendiary());
}
@@ -69,11 +70,13 @@ public class ExplosionPrimeEvent extends EntityEvent implements Cancellable {
this.fire = fire;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.entity;
import org.bukkit.entity.Firework;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a firework explodes.
@@ -12,7 +13,7 @@ public class FireworkExplodeEvent extends EntityEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel;
public FireworkExplodeEvent(final Firework what) {
public FireworkExplodeEvent(@NotNull final Firework what) {
super(what);
}
@@ -33,16 +34,19 @@ public class FireworkExplodeEvent extends EntityEvent implements Cancellable {
this.cancel = cancel;
}
@NotNull
@Override
public Firework getEntity() {
return (Firework) super.getEntity();
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.entity;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a human entity's food level changes
@@ -12,11 +13,12 @@ public class FoodLevelChangeEvent extends EntityEvent implements Cancellable {
private boolean cancel = false;
private int level;
public FoodLevelChangeEvent(final HumanEntity what, final int level) {
public FoodLevelChangeEvent(@NotNull final HumanEntity what, final int level) {
super(what);
this.level = level;
}
@NotNull
@Override
public HumanEntity getEntity() {
return (HumanEntity) entity;
@@ -55,11 +57,13 @@ public class FoodLevelChangeEvent extends EntityEvent 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.entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.entity.AbstractHorse;
import org.jetbrains.annotations.NotNull;
/**
* Called when a horse jumps.
@@ -12,7 +13,7 @@ public class HorseJumpEvent extends EntityEvent implements Cancellable {
private boolean cancelled;
private float power;
public HorseJumpEvent(final AbstractHorse horse, final float power) {
public HorseJumpEvent(@NotNull final AbstractHorse horse, final float power) {
super(horse);
this.power = power;
}
@@ -29,6 +30,7 @@ public class HorseJumpEvent extends EntityEvent implements Cancellable {
cancelled = cancel;
}
@NotNull
@Override
public AbstractHorse getEntity() {
return (AbstractHorse) entity;
@@ -73,11 +75,13 @@ public class HorseJumpEvent extends EntityEvent implements Cancellable {
this.power = power;
}
@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.entity.Item;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* This event is called when a {@link org.bukkit.entity.Item} is removed from
@@ -17,7 +18,7 @@ public class ItemDespawnEvent extends EntityEvent implements Cancellable {
private boolean canceled;
private final Location location;
public ItemDespawnEvent(final Item despawnee, final Location loc) {
public ItemDespawnEvent(@NotNull final Item despawnee, @NotNull final Location loc) {
super(despawnee);
location = loc;
}
@@ -30,6 +31,7 @@ public class ItemDespawnEvent extends EntityEvent implements Cancellable {
canceled = cancel;
}
@NotNull
@Override
public Item getEntity() {
return (Item) entity;
@@ -40,15 +42,18 @@ public class ItemDespawnEvent extends EntityEvent implements Cancellable {
*
* @return The location at which the item is despawning
*/
@NotNull
public Location getLocation() {
return location;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.entity;
import org.bukkit.entity.Item;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
public class ItemMergeEvent extends EntityEvent implements Cancellable {
@@ -10,7 +11,7 @@ public class ItemMergeEvent extends EntityEvent implements Cancellable {
private boolean cancelled;
private final Item target;
public ItemMergeEvent(Item item, Item target) {
public ItemMergeEvent(@NotNull Item item, @NotNull Item target) {
super(item);
this.target = target;
}
@@ -25,6 +26,7 @@ public class ItemMergeEvent extends EntityEvent implements Cancellable {
this.cancelled = cancelled;
}
@NotNull
@Override
public Item getEntity() {
return (Item) entity;
@@ -35,15 +37,18 @@ public class ItemMergeEvent extends EntityEvent implements Cancellable {
*
* @return The Item being merged with
*/
@NotNull
public Item getTarget() {
return target;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -1,7 +1,9 @@
package org.bukkit.event.entity;
import org.bukkit.Location;
import org.bukkit.UndefinedNullability;
import org.bukkit.entity.Item;
import org.jetbrains.annotations.NotNull;
/**
* Called when an item is spawned into a world
@@ -9,14 +11,15 @@ import org.bukkit.entity.Item;
public class ItemSpawnEvent extends EntitySpawnEvent {
@Deprecated
public ItemSpawnEvent(final Item spawnee, final Location loc) {
public ItemSpawnEvent(@NotNull final Item spawnee, final Location loc) {
this(spawnee);
}
public ItemSpawnEvent(final Item spawnee) {
public ItemSpawnEvent(@NotNull final Item spawnee) {
super(spawnee);
}
@NotNull
@Override
public Item getEntity() {
return (Item) entity;

View File

@@ -5,6 +5,7 @@ import org.bukkit.entity.LingeringPotion;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a splash potion hits an area
@@ -14,11 +15,12 @@ public class LingeringPotionSplashEvent extends ProjectileHitEvent implements Ca
private boolean cancelled;
private final AreaEffectCloud entity;
public LingeringPotionSplashEvent(final ThrownPotion potion, final AreaEffectCloud entity) {
public LingeringPotionSplashEvent(@NotNull final ThrownPotion potion, @NotNull final AreaEffectCloud entity) {
super(potion);
this.entity = entity;
}
@NotNull
@Override
public LingeringPotion getEntity() {
return (LingeringPotion) super.getEntity();
@@ -29,6 +31,7 @@ public class LingeringPotionSplashEvent extends ProjectileHitEvent implements Ca
*
* @return The spawned AreaEffectCloud
*/
@NotNull
public AreaEffectCloud getAreaEffectCloud() {
return entity;
}
@@ -41,11 +44,13 @@ public class LingeringPotionSplashEvent extends ProjectileHitEvent implements Ca
cancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -7,6 +7,7 @@ import org.bukkit.entity.Pig;
import org.bukkit.entity.PigZombie;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Stores data for pigs being zapped
@@ -17,7 +18,7 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable {
private final PigZombie pigzombie;
private final LightningStrike bolt;
public PigZapEvent(final Pig pig, final LightningStrike bolt, final PigZombie pigzombie) {
public PigZapEvent(@NotNull final Pig pig, @NotNull final LightningStrike bolt, @NotNull final PigZombie pigzombie) {
super(pig, Collections.singletonList((Entity) pigzombie), TransformReason.LIGHTNING);
this.bolt = bolt;
this.pigzombie = pigzombie;
@@ -31,6 +32,7 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable {
canceled = cancel;
}
@NotNull
@Override
public Pig getEntity() {
return (Pig) entity;
@@ -41,6 +43,7 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable {
*
* @return lightning entity
*/
@NotNull
public LightningStrike getLightning() {
return bolt;
}
@@ -52,16 +55,19 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable {
* @return resulting entity
* @deprecated use {@link EntityTransformEvent#getTransformedEntity()}
*/
@NotNull
@Deprecated
public PigZombie getPigZombie() {
return pigzombie;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,8 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.PigZombie;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when a Pig Zombie is angered by another entity.
@@ -17,7 +19,7 @@ public class PigZombieAngerEvent extends EntityEvent implements Cancellable {
private final Entity target;
private int newAnger;
public PigZombieAngerEvent(final PigZombie pigZombie, final Entity target, final int newAnger) {
public PigZombieAngerEvent(@NotNull final PigZombie pigZombie, @Nullable final Entity target, final int newAnger) {
super(pigZombie);
this.target = target;
this.newAnger = newAnger;
@@ -28,6 +30,7 @@ public class PigZombieAngerEvent extends EntityEvent implements Cancellable {
*
* @return triggering entity, or null
*/
@Nullable
public Entity getTarget() {
return target;
}
@@ -52,6 +55,7 @@ public class PigZombieAngerEvent extends EntityEvent implements Cancellable {
this.newAnger = newAnger;
}
@NotNull
@Override
public PigZombie getEntity() {
return (PigZombie) entity;
@@ -67,11 +71,13 @@ public class PigZombieAngerEvent extends EntityEvent implements Cancellable {
canceled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,8 @@ import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Thrown whenever a {@link Player} dies
@@ -16,15 +18,15 @@ public class PlayerDeathEvent extends EntityDeathEvent {
private boolean keepLevel = false;
private boolean keepInventory = false;
public PlayerDeathEvent(final Player player, final List<ItemStack> drops, final int droppedExp, final String deathMessage) {
public PlayerDeathEvent(@NotNull final Player player, @NotNull final List<ItemStack> drops, final int droppedExp, @Nullable final String deathMessage) {
this(player, drops, droppedExp, 0, deathMessage);
}
public PlayerDeathEvent(final Player player, final List<ItemStack> drops, final int droppedExp, final int newExp, final String deathMessage) {
public PlayerDeathEvent(@NotNull final Player player, @NotNull final List<ItemStack> drops, final int droppedExp, final int newExp, @Nullable final String deathMessage) {
this(player, drops, droppedExp, newExp, 0, 0, deathMessage);
}
public PlayerDeathEvent(final Player player, final List<ItemStack> drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, final String deathMessage) {
public PlayerDeathEvent(@NotNull final Player player, @NotNull final List<ItemStack> drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final String deathMessage) {
super(player, drops, droppedExp);
this.newExp = newExp;
this.newTotalExp = newTotalExp;
@@ -32,6 +34,7 @@ public class PlayerDeathEvent extends EntityDeathEvent {
this.deathMessage = deathMessage;
}
@NotNull
@Override
public Player getEntity() {
return (Player) entity;
@@ -42,7 +45,7 @@ public class PlayerDeathEvent extends EntityDeathEvent {
*
* @param deathMessage Message to appear to other players on the server.
*/
public void setDeathMessage(String deathMessage) {
public void setDeathMessage(@Nullable String deathMessage) {
this.deathMessage = deathMessage;
}
@@ -51,6 +54,7 @@ public class PlayerDeathEvent extends EntityDeathEvent {
*
* @return Message to appear to other players on the server.
*/
@Nullable
public String getDeathMessage() {
return deathMessage;
}

View File

@@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called immediately prior to a creature being leashed by a player.
@@ -16,7 +17,7 @@ public class PlayerLeashEntityEvent extends Event implements Cancellable {
private boolean cancelled = false;
private final Player player;
public PlayerLeashEntityEvent(Entity what, Entity leashHolder, Player leasher) {
public PlayerLeashEntityEvent(@NotNull Entity what, @NotNull Entity leashHolder, @NotNull Player leasher) {
this.leashHolder = leashHolder;
this.entity = what;
this.player = leasher;
@@ -27,6 +28,7 @@ public class PlayerLeashEntityEvent extends Event implements Cancellable {
*
* @return The leash holder
*/
@NotNull
public Entity getLeashHolder() {
return leashHolder;
}
@@ -36,6 +38,7 @@ public class PlayerLeashEntityEvent extends Event implements Cancellable {
*
* @return The entity
*/
@NotNull
public Entity getEntity() {
return entity;
}
@@ -45,15 +48,18 @@ public class PlayerLeashEntityEvent extends Event implements Cancellable {
*
* @return Player who is involved in this event
*/
@NotNull
public final Player getPlayer() {
return player;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -9,6 +9,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a splash potion hits an area
@@ -18,12 +19,13 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable
private boolean cancelled;
private final Map<LivingEntity, Double> affectedEntities;
public PotionSplashEvent(final ThrownPotion potion, final Map<LivingEntity, Double> affectedEntities) {
public PotionSplashEvent(@NotNull final ThrownPotion potion, @NotNull final Map<LivingEntity, Double> affectedEntities) {
super(potion);
this.affectedEntities = affectedEntities;
}
@NotNull
@Override
public ThrownPotion getEntity() {
return (ThrownPotion) entity;
@@ -34,6 +36,7 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable
*
* @return The thrown potion entity
*/
@NotNull
public ThrownPotion getPotion() {
return (ThrownPotion) getEntity();
}
@@ -43,6 +46,7 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable
*
* @return A fresh copy of the affected entity list
*/
@NotNull
public Collection<LivingEntity> getAffectedEntities() {
return new ArrayList<LivingEntity>(affectedEntities.keySet());
}
@@ -55,7 +59,7 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable
* @return intensity relative to maximum effect; 0.0: not affected; 1.0:
* fully hit by potion effects
*/
public double getIntensity(LivingEntity entity) {
public double getIntensity(@NotNull LivingEntity entity) {
Double intensity = affectedEntities.get(entity);
return intensity != null ? intensity : 0.0;
}
@@ -66,7 +70,7 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable
* @param entity For which entity to define a new intensity
* @param intensity relative to maximum effect
*/
public void setIntensity(LivingEntity entity, double intensity) {
public void setIntensity(@NotNull LivingEntity entity, double intensity) {
Validate.notNull(entity, "You must specify a valid entity.");
if (intensity <= 0.0) {
affectedEntities.remove(entity);
@@ -83,11 +87,13 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable
cancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -5,6 +5,8 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Projectile;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when a projectile hits an object
@@ -15,29 +17,30 @@ public class ProjectileHitEvent extends EntityEvent {
private final Block hitBlock;
private final BlockFace hitFace;
public ProjectileHitEvent(final Projectile projectile) {
public ProjectileHitEvent(@NotNull final Projectile projectile) {
this(projectile, null, null);
}
public ProjectileHitEvent(final Projectile projectile, Entity hitEntity) {
public ProjectileHitEvent(@NotNull final Projectile projectile, @Nullable Entity hitEntity) {
this(projectile, hitEntity, null);
}
public ProjectileHitEvent(final Projectile projectile, Block hitBlock) {
public ProjectileHitEvent(@NotNull final Projectile projectile, @Nullable Block hitBlock) {
this(projectile, null, hitBlock);
}
public ProjectileHitEvent(final Projectile projectile, Entity hitEntity, Block hitBlock) {
public ProjectileHitEvent(@NotNull final Projectile projectile, @Nullable Entity hitEntity, @Nullable Block hitBlock) {
this(projectile, hitEntity, hitBlock, null);
}
public ProjectileHitEvent(final Projectile projectile, Entity hitEntity, Block hitBlock, BlockFace hitFace) {
public ProjectileHitEvent(@NotNull final Projectile projectile, @Nullable Entity hitEntity, @Nullable Block hitBlock, @Nullable BlockFace hitFace) {
super(projectile);
this.hitEntity = hitEntity;
this.hitBlock = hitBlock;
this.hitFace = hitFace;
}
@NotNull
@Override
public Projectile getEntity() {
return (Projectile) entity;
@@ -48,6 +51,7 @@ public class ProjectileHitEvent extends EntityEvent {
*
* @return hit block or else null
*/
@Nullable
public Block getHitBlock() {
return hitBlock;
}
@@ -58,6 +62,7 @@ public class ProjectileHitEvent extends EntityEvent {
*
* @return hit face or else null
*/
@Nullable
public BlockFace getHitBlockFace() {
return hitFace;
}
@@ -67,15 +72,18 @@ public class ProjectileHitEvent extends EntityEvent {
*
* @return hit entity or else null
*/
@Nullable
public Entity getHitEntity() {
return hitEntity;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.entity;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Projectile;
import org.bukkit.event.Cancellable;
import org.jetbrains.annotations.NotNull;
/**
* Called when a projectile is launched.
@@ -10,7 +11,7 @@ import org.bukkit.event.Cancellable;
public class ProjectileLaunchEvent extends EntitySpawnEvent implements Cancellable {
private boolean cancelled;
public ProjectileLaunchEvent(Entity what) {
public ProjectileLaunchEvent(@NotNull Entity what) {
super(what);
}
@@ -22,6 +23,7 @@ public class ProjectileLaunchEvent extends EntitySpawnEvent implements Cancellab
cancelled = cancel;
}
@NotNull
@Override
public Projectile getEntity() {
return (Projectile) entity;

View File

@@ -4,6 +4,7 @@ import org.bukkit.DyeColor;
import org.bukkit.entity.Sheep;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a sheep's wool is dyed
@@ -13,7 +14,7 @@ public class SheepDyeWoolEvent extends EntityEvent implements Cancellable {
private boolean cancel;
private DyeColor color;
public SheepDyeWoolEvent(final Sheep sheep, final DyeColor color) {
public SheepDyeWoolEvent(@NotNull final Sheep sheep, @NotNull final DyeColor color) {
super(sheep);
this.cancel = false;
this.color = color;
@@ -27,6 +28,7 @@ public class SheepDyeWoolEvent extends EntityEvent implements Cancellable {
this.cancel = cancel;
}
@NotNull
@Override
public Sheep getEntity() {
return (Sheep) entity;
@@ -37,6 +39,7 @@ public class SheepDyeWoolEvent extends EntityEvent implements Cancellable {
*
* @return the DyeColor the sheep is being dyed
*/
@NotNull
public DyeColor getColor() {
return color;
}
@@ -46,15 +49,17 @@ public class SheepDyeWoolEvent extends EntityEvent implements Cancellable {
*
* @param color the DyeColor the sheep will be dyed
*/
public void setColor(DyeColor color) {
public void setColor(@NotNull DyeColor color) {
this.color = color;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.entity;
import org.bukkit.entity.Sheep;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a sheep regrows its wool
@@ -11,7 +12,7 @@ public class SheepRegrowWoolEvent extends EntityEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel;
public SheepRegrowWoolEvent(final Sheep sheep) {
public SheepRegrowWoolEvent(@NotNull final Sheep sheep) {
super(sheep);
this.cancel = false;
}
@@ -24,16 +25,19 @@ public class SheepRegrowWoolEvent extends EntityEvent implements Cancellable {
this.cancel = cancel;
}
@NotNull
@Override
public Sheep getEntity() {
return (Sheep) entity;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.entity;
import org.bukkit.entity.Slime;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a Slime splits into smaller Slimes upon death
@@ -12,7 +13,7 @@ public class SlimeSplitEvent extends EntityEvent implements Cancellable {
private boolean cancel = false;
private int count;
public SlimeSplitEvent(final Slime slime, final int count) {
public SlimeSplitEvent(@NotNull final Slime slime, final int count) {
super(slime);
this.count = count;
}
@@ -25,6 +26,7 @@ public class SlimeSplitEvent extends EntityEvent implements Cancellable {
this.cancel = cancel;
}
@NotNull
@Override
public Slime getEntity() {
return (Slime) entity;
@@ -48,11 +50,13 @@ public class SlimeSplitEvent extends EntityEvent implements Cancellable {
this.count = count;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.entity.Villager;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.MerchantRecipe;
import org.jetbrains.annotations.NotNull;
/**
* Called whenever a villager acquires a new trade.
@@ -15,7 +16,7 @@ public class VillagerAcquireTradeEvent extends EntityEvent implements Cancellabl
//
private MerchantRecipe recipe;
public VillagerAcquireTradeEvent(Villager what, MerchantRecipe recipe) {
public VillagerAcquireTradeEvent(@NotNull Villager what, @NotNull MerchantRecipe recipe) {
super(what);
this.recipe = recipe;
}
@@ -25,6 +26,7 @@ public class VillagerAcquireTradeEvent extends EntityEvent implements Cancellabl
*
* @return the new recipe
*/
@NotNull
public MerchantRecipe getRecipe() {
return recipe;
}
@@ -34,7 +36,7 @@ public class VillagerAcquireTradeEvent extends EntityEvent implements Cancellabl
*
* @param recipe the new recipe
*/
public void setRecipe(MerchantRecipe recipe) {
public void setRecipe(@NotNull MerchantRecipe recipe) {
this.recipe = recipe;
}
@@ -48,16 +50,19 @@ public class VillagerAcquireTradeEvent extends EntityEvent implements Cancellabl
this.cancelled = cancel;
}
@NotNull
@Override
public Villager getEntity() {
return (Villager) super.getEntity();
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.entity.Villager;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.MerchantRecipe;
import org.jetbrains.annotations.NotNull;
/**
* Called when a villager's trade's maximum uses is increased, due to a player's
@@ -19,7 +20,7 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella
private MerchantRecipe recipe;
private int bonus;
public VillagerReplenishTradeEvent(Villager what, MerchantRecipe recipe, int bonus) {
public VillagerReplenishTradeEvent(@NotNull Villager what, @NotNull MerchantRecipe recipe, int bonus) {
super(what);
this.recipe = recipe;
this.bonus = bonus;
@@ -30,6 +31,7 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella
*
* @return the replenished recipe
*/
@NotNull
public MerchantRecipe getRecipe() {
return recipe;
}
@@ -39,7 +41,7 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella
*
* @param recipe the replenished recipe
*/
public void setRecipe(MerchantRecipe recipe) {
public void setRecipe(@NotNull MerchantRecipe recipe) {
this.recipe = recipe;
}
@@ -73,16 +75,19 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella
this.cancelled = cancel;
}
@NotNull
@Override
public Villager getEntity() {
return (Villager) super.getEntity();
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -2,6 +2,8 @@ package org.bukkit.event.hanging;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Hanging;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Triggered when a hanging entity is removed by an entity
@@ -9,20 +11,22 @@ import org.bukkit.entity.Hanging;
public class HangingBreakByEntityEvent extends HangingBreakEvent {
private final Entity remover;
public HangingBreakByEntityEvent(final Hanging hanging, final Entity remover) {
public HangingBreakByEntityEvent(@NotNull final Hanging hanging, @Nullable final Entity remover) {
this(hanging, remover, HangingBreakEvent.RemoveCause.ENTITY);
}
public HangingBreakByEntityEvent(final Hanging hanging, final Entity remover, final HangingBreakEvent.RemoveCause cause) {
public HangingBreakByEntityEvent(@NotNull final Hanging hanging, @Nullable final Entity remover, @NotNull final HangingBreakEvent.RemoveCause cause) {
super(hanging, cause);
this.remover = remover;
}
/**
* Gets the entity that removed the hanging entity
* Gets the entity that removed the hanging entity.
* May be null, for example when broken by an explosion.
*
* @return the entity that removed the hanging entity
*/
@Nullable
public Entity getRemover() {
return remover;
}

View File

@@ -3,6 +3,7 @@ package org.bukkit.event.hanging;
import org.bukkit.entity.Hanging;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Triggered when a hanging entity is removed
@@ -12,7 +13,7 @@ public class HangingBreakEvent extends HangingEvent implements Cancellable {
private boolean cancelled;
private final HangingBreakEvent.RemoveCause cause;
public HangingBreakEvent(final Hanging hanging, final HangingBreakEvent.RemoveCause cause) {
public HangingBreakEvent(@NotNull final Hanging hanging, @NotNull final HangingBreakEvent.RemoveCause cause) {
super(hanging);
this.cause = cause;
}
@@ -22,6 +23,7 @@ public class HangingBreakEvent extends HangingEvent implements Cancellable {
*
* @return the RemoveCause for the hanging entity's removal
*/
@NotNull
public HangingBreakEvent.RemoveCause getCause() {
return cause;
}
@@ -60,11 +62,13 @@ public class HangingBreakEvent extends HangingEvent implements Cancellable {
DEFAULT,
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.event.hanging;
import org.bukkit.entity.Hanging;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
/**
* Represents a hanging entity-related event.
@@ -9,7 +10,7 @@ import org.bukkit.event.Event;
public abstract class HangingEvent extends Event {
protected Hanging hanging;
protected HangingEvent(final Hanging painting) {
protected HangingEvent(@NotNull final Hanging painting) {
this.hanging = painting;
}
@@ -18,6 +19,7 @@ public abstract class HangingEvent extends Event {
*
* @return the hanging entity
*/
@NotNull
public Hanging getEntity() {
return hanging;
}

View File

@@ -6,6 +6,8 @@ import org.bukkit.entity.Hanging;
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;
/**
* Triggered when a hanging entity is created in the world
@@ -17,7 +19,7 @@ public class HangingPlaceEvent extends HangingEvent implements Cancellable {
private final Block block;
private final BlockFace blockFace;
public HangingPlaceEvent(final Hanging hanging, final Player player, final Block block, final BlockFace blockFace) {
public HangingPlaceEvent(@NotNull final Hanging hanging, @Nullable final Player player, @NotNull final Block block, @NotNull final BlockFace blockFace) {
super(hanging);
this.player = player;
this.block = block;
@@ -29,6 +31,7 @@ public class HangingPlaceEvent extends HangingEvent implements Cancellable {
*
* @return the player placing the hanging entity
*/
@Nullable
public Player getPlayer() {
return player;
}
@@ -38,6 +41,7 @@ public class HangingPlaceEvent extends HangingEvent implements Cancellable {
*
* @return the block that the hanging entity was placed on
*/
@NotNull
public Block getBlock() {
return block;
}
@@ -47,6 +51,7 @@ public class HangingPlaceEvent extends HangingEvent implements Cancellable {
*
* @return the face of the block that the hanging entity was placed on
*/
@NotNull
public BlockFace getBlockFace() {
return blockFace;
}
@@ -59,11 +64,13 @@ public class HangingPlaceEvent extends HangingEvent implements Cancellable {
this.cancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

Some files were not shown because too many files have changed in this diff Show More