Begin switching to JSpecify annotations (#11448)

* Begin switching to JSpecify annotations

* more

* fixes
This commit is contained in:
Jake Potrebic
2024-09-29 12:52:13 -07:00
parent fa1f6a5d78
commit 64e918335c
62 changed files with 580 additions and 750 deletions

View File

@@ -21,8 +21,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.event.entity.EntityEvent;
+import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.ApiStatus;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.NullMarked;
+import org.jspecify.annotations.Nullable;
+
+/**
+ * Called when two entities mate and the mating process results in a fertilization.
@@ -35,23 +35,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * <li>Sniffers producing the {@link Material#SNIFFER_EGG} item, which needs to be placed before it can begin to hatch.</li>
+ * <li>A turtle being marked with "HasEgg" and laying a {@link Material#TURTLE_EGG} later.</li>
+ * </ul>
+ *
+ * <p>
+ * The event hence only exposes the two parent entities in the fertilization process and cannot provide the child entity, as it will only exist at a later point in time.
+ */
+@NullMarked
+public class EntityFertilizeEggEvent extends EntityEvent implements Cancellable {
+
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private final LivingEntity mother;
+ private final LivingEntity father;
+ private final Player breeder;
+ private final ItemStack bredWith;
+ private final @Nullable Player breeder;
+ private final @Nullable ItemStack bredWith;
+ private int experience;
+
+ private boolean cancelled;
+
+ @ApiStatus.Internal
+ public EntityFertilizeEggEvent(@NotNull LivingEntity mother, @NotNull LivingEntity father, @Nullable Player breeder, @Nullable ItemStack bredWith, int experience) {
+ public EntityFertilizeEggEvent(final LivingEntity mother, final LivingEntity father, final @Nullable Player breeder, final @Nullable ItemStack bredWith, final int experience) {
+ super(mother);
+ this.mother = mother;
+ this.father = father;
@@ -60,7 +61,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ this.experience = experience;
+ }
+
+ @NotNull
+ @Override
+ public LivingEntity getEntity() {
+ return (LivingEntity) super.getEntity();
@@ -72,7 +72,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return The "mother" entity.
+ */
+ @NotNull
+ public LivingEntity getMother() {
+ return this.mother;
+ }
@@ -83,7 +82,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return the other parent
+ */
+ @NotNull
+ public LivingEntity getFather() {
+ return this.father;
+ }
@@ -94,8 +92,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return The Entity who initiated fertilization.
+ */
+ @Nullable
+ public Player getBreeder() {
+ public @Nullable Player getBreeder() {
+ return this.breeder;
+ }
+
@@ -104,8 +101,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @return ItemStack used to initiate fertilization.
+ */
+ @Nullable
+ public ItemStack getBredWith() {
+ public @Nullable ItemStack getBredWith() {
+ return this.bredWith;
+ }
+
@@ -124,7 +120,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ *
+ * @param experience experience amount
+ */
+ public void setExperience(int experience) {
+ public void setExperience(final int experience) {
+ this.experience = experience;
+ }
+
@@ -134,17 +130,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ public void setCancelled(final boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLER_LIST;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return HANDLER_LIST;
+ }