SPIGOT-2540: Add nullability annotations to entire Bukkit API

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

View File

@@ -6,6 +6,7 @@ import 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;
}