Swap some nullable annotations (#9696)

This commit is contained in:
Lulu13022002 2023-09-14 12:44:12 +02:00
parent 11f2c20c6a
commit abbdae4f53
9 changed files with 171 additions and 57 deletions

View File

@ -13,26 +13,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+package io.papermc.paper.event.entity;
+
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.inventory.EquipmentSlot;
+import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Called when a LivingEntity loads a crossbow with a projectile.
+ */
+public class EntityLoadCrossbowEvent extends EntityEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final ItemStack crossbow;
+ private final EquipmentSlot hand;
+ private boolean cancelled;
+ private boolean consumeItem = true;
+
+ public EntityLoadCrossbowEvent(@NotNull LivingEntity entity, @Nullable ItemStack crossbow, @NotNull EquipmentSlot hand) {
+ @ApiStatus.Internal
+ public EntityLoadCrossbowEvent(@NotNull LivingEntity entity, @NotNull ItemStack crossbow, @NotNull EquipmentSlot hand) {
+ super(entity);
+ this.crossbow = crossbow;
+ this.hand = hand;
@ -49,7 +50,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return the crossbow involved in this event
+ */
+ @Nullable
+ @NotNull
+ public ItemStack getCrossbow() {
+ return crossbow;
+ }
@ -99,11 +100,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ return HANDLER_LIST;
+ }
+}

View File

@ -16,6 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.EntityType;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
@ -26,6 +27,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+public class PhantomPreSpawnEvent extends PreCreatureSpawnEvent {
+ @NotNull private final Entity entity;
+
+ @ApiStatus.Internal
+ public PhantomPreSpawnEvent(@NotNull Location location, @NotNull Entity entity, @NotNull CreatureSpawnEvent.SpawnReason reason) {
+ super(location, EntityType.PHANTOM, reason);
+ this.entity = entity;
@ -36,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return Entity
+ */
+ @Nullable
+ @NotNull
+ public Entity getSpawningEntity() {
+ return entity;
+ }

View File

@ -22,6 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
@ -36,10 +37,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private static final HandlerList HANDLERS = new HandlerList();
+
+ @NotNull private final SlotType slotType;
+ @Nullable private final ItemStack oldItem;
+ @Nullable private final ItemStack newItem;
+ @NotNull private final ItemStack oldItem;
+ @NotNull private final ItemStack newItem;
+
+ public PlayerArmorChangeEvent(@NotNull Player player, @NotNull SlotType slotType, @Nullable ItemStack oldItem, @Nullable ItemStack newItem) {
+ @ApiStatus.Internal
+ public PlayerArmorChangeEvent(@NotNull Player player, @NotNull SlotType slotType, @NotNull ItemStack oldItem, @NotNull ItemStack newItem) {
+ super(player);
+ this.slotType = slotType;
+ this.oldItem = oldItem;
@ -61,7 +63,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return old item
+ */
+ @Nullable
+ @NotNull
+ public ItemStack getOldItem() {
+ return this.oldItem;
+ }
@ -71,7 +73,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return new item
+ */
+ @Nullable
+ @NotNull
+ public ItemStack getNewItem() {
+ return this.newItem;
+ }
@ -137,10 +139,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+
+ /**
+ * Gets whether or not this material can be equipped to a slot
+ * Gets whether this material can be equipped to a slot
+ *
+ * @param material material to check
+ * @return whether or not this material can be equipped
+ * @return whether this material can be equipped
+ */
+ public static boolean isEquipable(@NotNull Material material) {
+ return getByMaterial(material) != null;

View File

@ -33,7 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final Side side;
+
+ @ApiStatus.Internal
+ public PlayerSignCommandPreprocessEvent(@NotNull Player player, @NotNull String message, @NotNull Set<Player> recipients, @NotNull Sign sign, final Side side) {
+ public PlayerSignCommandPreprocessEvent(@NotNull Player player, @NotNull String message, @NotNull Set<Player> recipients, @NotNull Sign sign, @NotNull Side side) {
+ super(player, message, recipients);
+ this.sign = sign;
+ this.side = side;

View File

@ -19,8 +19,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.entity.EntityEvent;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Called when a Warden's anger level has changed due to another entity.
@ -29,13 +29,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ */
+public class WardenAngerChangeEvent extends EntityEvent implements Cancellable {
+
+ private static final HandlerList handlers = new HandlerList();
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private boolean cancelled;
+ private final Entity target;
+ private final int oldAnger;
+ private int newAnger;
+
+ public WardenAngerChangeEvent(@NotNull final Warden warden, @Nullable final Entity target, final int oldAnger, final int newAnger) {
+ @ApiStatus.Internal
+ public WardenAngerChangeEvent(@NotNull final Warden warden, @NotNull final Entity target, final int oldAnger, final int newAnger) {
+ super(warden);
+ this.target = target;
+ this.oldAnger = oldAnger;
@ -43,11 +45,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+
+ /**
+ * Gets the entity (if any) which triggered this anger update.
+ * Gets the entity which triggered this anger update.
+ *
+ * @return triggering entity, or null
+ * @return triggering entity
+ */
+ @Nullable
+ @NotNull
+ public Entity getTarget() {
+ return target;
+ }
@ -107,11 +109,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ return HANDLER_LIST;
+ }
+}

View File

@ -18,6 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.potion.PotionEffectType;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
@ -25,7 +26,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Called when a player sets the effect for a beacon
+ */
+public class PlayerChangeBeaconEffectEvent extends PlayerEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private PotionEffectType primary;
+ private PotionEffectType secondary;
@ -34,7 +35,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ private boolean isCancelled;
+
+ public PlayerChangeBeaconEffectEvent(@NotNull Player player, @Nullable PotionEffectType primary, @Nullable PotionEffectType secondary, @Nullable Block beacon) {
+ @ApiStatus.Internal
+ public PlayerChangeBeaconEffectEvent(@NotNull Player player, @Nullable PotionEffectType primary, @Nullable PotionEffectType secondary, @NotNull Block beacon) {
+ super(player);
+ this.primary = primary;
+ this.secondary = secondary;
@ -80,9 +82,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+
+ /**
+ * @return the beacon block associated with this event, or null if not found
+ * @return the beacon block associated with this event
+ */
+ @Nullable
+ @NotNull
+ public Block getBeacon() {
+ return beacon;
+ }
@ -143,11 +145,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ @Override
+ public @NotNull HandlerList getHandlers() {
+ return handlers;
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ return HANDLER_LIST;
+ }
+}

View File

@ -19,6 +19,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.inventory.InventoryEvent;
+import org.bukkit.inventory.AnvilInventory;
+import org.bukkit.inventory.InventoryView;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
@ -26,11 +27,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * Called when an anvil is damaged from being used
+ */
+public class AnvilDamagedEvent extends InventoryEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private boolean cancel;
+ private DamageState damageState;
+
+ public AnvilDamagedEvent(@NotNull InventoryView inventory, @NotNull BlockData blockData) {
+ @ApiStatus.Internal
+ public AnvilDamagedEvent(@NotNull InventoryView inventory, @Nullable BlockData blockData) {
+ super(inventory);
+ this.damageState = DamageState.getState(blockData);
+ }
@ -92,12 +95,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ return HANDLER_LIST;
+ }
+
+ /**
@ -109,7 +112,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ DAMAGED(Material.DAMAGED_ANVIL),
+ BROKEN(Material.AIR);
+
+ private Material material;
+ private final Material material;
+
+ DamageState(@NotNull Material material) {
+ this.material = material;
@ -154,7 +157,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return state;
+ }
+ }
+ throw new IllegalArgumentException("Material not an anvil");
+ throw new IllegalArgumentException("Material is not an anvil state");
+ }
+ }
+}

View File

@ -20,17 +20,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.entity.EntityEvent;
+
+import java.util.Collection;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Fired when a DragonFireball collides with a block/entity and spawns an AreaEffectCloud
+ */
+public class EnderDragonFireballHitEvent extends EntityEvent implements Cancellable {
+ @Nullable private final Collection<LivingEntity> targets;
+ @NotNull private final AreaEffectCloud areaEffectCloud;
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ public EnderDragonFireballHitEvent(@NotNull DragonFireball fireball, @Nullable Collection<LivingEntity> targets, @NotNull AreaEffectCloud areaEffectCloud) {
+ @NotNull private final Collection<LivingEntity> targets;
+ @NotNull private final AreaEffectCloud areaEffectCloud;
+ private boolean cancelled = false;
+
+ @ApiStatus.Internal
+ public EnderDragonFireballHitEvent(@NotNull DragonFireball fireball, @NotNull Collection<LivingEntity> targets, @NotNull AreaEffectCloud areaEffectCloud) {
+ super(fireball);
+ this.targets = targets;
+ this.areaEffectCloud = areaEffectCloud;
@ -48,11 +52,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ /**
+ * The living entities hit by fireball
+ *
+ * May be null if no entities were hit
+ *
+ * @return the targets
+ */
+ @Nullable
+ @NotNull
+ public Collection<LivingEntity> getTargets() {
+ return targets;
+ }
@ -65,20 +67,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return areaEffectCloud;
+ }
+
+ private static final HandlerList handlers = new HandlerList();
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ private boolean cancelled = false;
+
+ @Override
+ public boolean isCancelled() {
+ return cancelled;
@ -88,6 +76,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public void setCancelled(boolean cancel) {
+ cancelled = cancel;
+ }
+
+ @NotNull
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }
+}
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFlameEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EnderDragonFlameEvent.java
new file mode 100644

View File

@ -491,6 +491,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return offers;
}
diff --git a/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java b/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java
+++ b/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable;
* LivingEntity's.
*/
public class EntityTargetLivingEntityEvent extends EntityTargetEvent {
- public EntityTargetLivingEntityEvent(@NotNull final Entity entity, @Nullable final LivingEntity target, @Nullable final TargetReason reason) {
+ public EntityTargetLivingEntityEvent(@NotNull final Entity entity, @Nullable final LivingEntity target, @NotNull final TargetReason reason) { // Paper
super(entity, target, reason);
}
diff --git a/src/main/java/org/bukkit/event/entity/EntityToggleSwimEvent.java b/src/main/java/org/bukkit/event/entity/EntityToggleSwimEvent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/entity/EntityToggleSwimEvent.java
@ -510,6 +523,75 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public void setCancelled(boolean cancel) {
this.cancel = cancel;
diff --git a/src/main/java/org/bukkit/event/entity/SpawnerSpawnEvent.java b/src/main/java/org/bukkit/event/entity/SpawnerSpawnEvent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/entity/SpawnerSpawnEvent.java
+++ b/src/main/java/org/bukkit/event/entity/SpawnerSpawnEvent.java
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull;
public class SpawnerSpawnEvent extends EntitySpawnEvent {
private final CreatureSpawner spawner;
- public SpawnerSpawnEvent(@NotNull final Entity spawnee, @NotNull final CreatureSpawner spawner) {
+ public SpawnerSpawnEvent(@NotNull final Entity spawnee, @org.jetbrains.annotations.Nullable final CreatureSpawner spawner) { // Paper
super(spawnee);
this.spawner = spawner;
}
- @NotNull
+ /**
+ * Gets the spawner tile state, or null
+ * when the entity is spawned from a minecart
+ * spawner.
+ *
+ * @return the spawner tile state
+ */
+ @org.jetbrains.annotations.Nullable // Paper
public CreatureSpawner getSpawner() {
return spawner;
}
diff --git a/src/main/java/org/bukkit/event/hanging/HangingBreakByEntityEvent.java b/src/main/java/org/bukkit/event/hanging/HangingBreakByEntityEvent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/hanging/HangingBreakByEntityEvent.java
+++ b/src/main/java/org/bukkit/event/hanging/HangingBreakByEntityEvent.java
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable;
public class HangingBreakByEntityEvent extends HangingBreakEvent {
private final Entity remover;
- public HangingBreakByEntityEvent(@NotNull final Hanging hanging, @Nullable final Entity remover) {
+ public HangingBreakByEntityEvent(@NotNull final Hanging hanging, @NotNull final Entity remover) { // Paper
this(hanging, remover, HangingBreakEvent.RemoveCause.ENTITY);
}
- public HangingBreakByEntityEvent(@NotNull final Hanging hanging, @Nullable final Entity remover, @NotNull final HangingBreakEvent.RemoveCause cause) {
+ public HangingBreakByEntityEvent(@NotNull final Hanging hanging, @NotNull final Entity remover, @NotNull final HangingBreakEvent.RemoveCause cause) { // Paper
super(hanging, cause);
this.remover = remover;
}
/**
* 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
+ @NotNull // Paper
public Entity getRemover() {
return remover;
}
diff --git a/src/main/java/org/bukkit/event/inventory/HopperInventorySearchEvent.java b/src/main/java/org/bukkit/event/inventory/HopperInventorySearchEvent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/inventory/HopperInventorySearchEvent.java
+++ b/src/main/java/org/bukkit/event/inventory/HopperInventorySearchEvent.java
@@ -0,0 +0,0 @@ public class HopperInventorySearchEvent extends BlockEvent {
DESTINATION;
}
- public HopperInventorySearchEvent(@NotNull Inventory inventory, @NotNull ContainerType containerType, @NotNull Block hopper, @NotNull Block searchBlock) {
+ public HopperInventorySearchEvent(@Nullable Inventory inventory, @NotNull ContainerType containerType, @NotNull Block hopper, @NotNull Block searchBlock) { // Paper
super(hopper);
this.inventory = inventory;
this.containerType = containerType;
diff --git a/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java b/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java
@ -523,6 +605,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public Location getTo() {
return to;
}
diff --git a/src/main/java/org/bukkit/event/raid/RaidSpawnWaveEvent.java b/src/main/java/org/bukkit/event/raid/RaidSpawnWaveEvent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/raid/RaidSpawnWaveEvent.java
+++ b/src/main/java/org/bukkit/event/raid/RaidSpawnWaveEvent.java
@@ -0,0 +0,0 @@ public class RaidSpawnWaveEvent extends RaidEvent {
private final List<Raider> raiders;
private final Raider leader;
- public RaidSpawnWaveEvent(@NotNull Raid raid, @NotNull World world, @Nullable Raider leader, @NotNull List<Raider> raiders) {
+ public RaidSpawnWaveEvent(@NotNull Raid raid, @NotNull World world, @NotNull Raider leader, @NotNull List<Raider> raiders) { // Paper
super(raid, world);
this.raiders = raiders;
this.leader = leader;
@@ -0,0 +0,0 @@ public class RaidSpawnWaveEvent extends RaidEvent {
*
* @return {@link Raider}
*/
- @Nullable
+ @NotNull // Paper
public Raider getPatrolLeader() {
return leader;
}
diff --git a/src/main/java/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.java b/src/main/java/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.java