diff --git a/paper-api/src/main/java/org/bukkit/spawner/BaseSpawner.java b/paper-api/src/main/java/org/bukkit/spawner/BaseSpawner.java index 553aa2dcca..4c78c0402b 100644 --- a/paper-api/src/main/java/org/bukkit/spawner/BaseSpawner.java +++ b/paper-api/src/main/java/org/bukkit/spawner/BaseSpawner.java @@ -8,13 +8,14 @@ import org.bukkit.block.spawner.SpawnerEntry; import org.bukkit.entity.EntitySnapshot; import org.bukkit.entity.EntityType; import org.bukkit.entity.minecart.SpawnerMinecart; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Represents a basic entity spawner.
* May be a {@link SpawnerMinecart}, {@link CreatureSpawner} or {@link TrialSpawnerConfiguration}. */ +@NullMarked public interface BaseSpawner { /** @@ -23,7 +24,7 @@ public interface BaseSpawner { * @return The creature type or null if it not set. */ @Nullable - public EntityType getSpawnedType(); + EntityType getSpawnedType(); /** * Set the spawner's creature type.
@@ -31,7 +32,7 @@ public interface BaseSpawner { * * @param creatureType The creature type or null to clear. */ - public void setSpawnedType(@Nullable EntityType creatureType); + void setSpawnedType(@Nullable EntityType creatureType); /** * Get the spawner's delay. @@ -40,14 +41,14 @@ public interface BaseSpawner { * * @return The delay. */ - public int getDelay(); + int getDelay(); /** * Set the spawner's delay. * * @param delay The delay. */ - public void setDelay(int delay); + void setDelay(int delay); /** * Get the maximum distance(squared) a player can be in order for this @@ -61,7 +62,7 @@ public interface BaseSpawner { * @return the maximum distance(squared) a player can be in order for this * spawner to be active. */ - public int getRequiredPlayerRange(); + int getRequiredPlayerRange(); /** * Set the maximum distance (squared) a player can be in order for this @@ -73,7 +74,7 @@ public interface BaseSpawner { * @param requiredPlayerRange the maximum distance (squared) a player can be * in order for this spawner to be active. */ - public void setRequiredPlayerRange(int requiredPlayerRange); + void setRequiredPlayerRange(int requiredPlayerRange); /** * Get the radius around which the spawner will attempt to spawn mobs in. @@ -89,7 +90,7 @@ public interface BaseSpawner { * * @return the spawn range */ - public int getSpawnRange(); + int getSpawnRange(); /** * Set the new spawn range. @@ -98,7 +99,7 @@ public interface BaseSpawner { * @param spawnRange the new spawn range * @see #getSpawnRange() */ - public void setSpawnRange(int spawnRange); + void setSpawnRange(int spawnRange); /** * Gets the {@link EntitySnapshot} that will be spawned by this spawner or null @@ -111,7 +112,7 @@ public interface BaseSpawner { * spawner. */ @Nullable - public EntitySnapshot getSpawnedEntity(); + EntitySnapshot getSpawnedEntity(); /** * Sets the entity that will be spawned by this spawner.
@@ -123,7 +124,7 @@ public interface BaseSpawner { * * @param snapshot the entity snapshot or null to clear */ - public void setSpawnedEntity(@Nullable EntitySnapshot snapshot); + void setSpawnedEntity(@Nullable EntitySnapshot snapshot); /** * Sets the {@link SpawnerEntry} that will be spawned by this spawner.
@@ -132,14 +133,14 @@ public interface BaseSpawner { * * @param spawnerEntry the spawner entry to use */ - public void setSpawnedEntity(@NotNull SpawnerEntry spawnerEntry); + void setSpawnedEntity(SpawnerEntry spawnerEntry); /** * Adds a new {@link EntitySnapshot} to the list of entities this spawner can * spawn. *

* The weight will determine how often this entry is chosen to spawn, higher - * weighted entries will spawn more often than lower weighted ones.
+ * weighted entries will spawn more often than lower-weighted ones.
* The {@link SpawnRule} will determine under what conditions this entry can * spawn, passing null will use the default conditions for the given entity. * @@ -147,7 +148,7 @@ public interface BaseSpawner { * @param weight the weight * @param spawnRule the spawn rule for this entity, or null */ - public void addPotentialSpawn(@NotNull EntitySnapshot snapshot, int weight, @Nullable SpawnRule spawnRule); + void addPotentialSpawn(EntitySnapshot snapshot, int weight, @Nullable SpawnRule spawnRule); /** * Adds a new {@link SpawnerEntry} to the list of entities this spawner can @@ -156,7 +157,7 @@ public interface BaseSpawner { * @param spawnerEntry the spawner entry to use * @see #addPotentialSpawn(EntitySnapshot, int, SpawnRule) */ - public void addPotentialSpawn(@NotNull final SpawnerEntry spawnerEntry); + void addPotentialSpawn(final SpawnerEntry spawnerEntry); /** * Sets the list of {@link SpawnerEntry} this spawner can spawn.
@@ -165,7 +166,7 @@ public interface BaseSpawner { * * @param entries the list of entries */ - public void setPotentialSpawns(@NotNull final Collection entries); + void setPotentialSpawns(final Collection entries); /** * Gets a list of potential spawns from this spawner or an empty list if no @@ -177,6 +178,5 @@ public interface BaseSpawner { * entities have been assigned to this spawner * @see #getSpawnedType() */ - @NotNull - public List getPotentialSpawns(); + List getPotentialSpawns(); } diff --git a/paper-api/src/main/java/org/bukkit/spawner/Spawner.java b/paper-api/src/main/java/org/bukkit/spawner/Spawner.java index 640767bd16..592c213901 100644 --- a/paper-api/src/main/java/org/bukkit/spawner/Spawner.java +++ b/paper-api/src/main/java/org/bukkit/spawner/Spawner.java @@ -3,11 +3,14 @@ package org.bukkit.spawner; import org.bukkit.block.CreatureSpawner; import org.bukkit.entity.EntityType; import org.bukkit.entity.minecart.SpawnerMinecart; +import org.bukkit.inventory.ItemStack; +import org.jspecify.annotations.NullMarked; /** * Represents an entity spawner.
* May be a {@link SpawnerMinecart} or a {@link CreatureSpawner}. */ +@NullMarked public interface Spawner extends BaseSpawner { /** @@ -19,7 +22,7 @@ public interface Spawner extends BaseSpawner { * @param delay The delay. */ @Override - public void setDelay(int delay); + void setDelay(int delay); /** * The minimum spawn delay amount (in ticks). @@ -32,7 +35,7 @@ public interface Spawner extends BaseSpawner { * * @return the minimum spawn delay amount */ - public int getMinSpawnDelay(); + int getMinSpawnDelay(); /** * Set the minimum spawn delay amount (in ticks). @@ -40,7 +43,7 @@ public interface Spawner extends BaseSpawner { * @param delay the minimum spawn delay amount * @see #getMinSpawnDelay() */ - public void setMinSpawnDelay(int delay); + void setMinSpawnDelay(int delay); /** * The maximum spawn delay amount (in ticks). @@ -56,7 +59,7 @@ public interface Spawner extends BaseSpawner { * * @return the maximum spawn delay amount */ - public int getMaxSpawnDelay(); + int getMaxSpawnDelay(); /** * Set the maximum spawn delay amount (in ticks). @@ -67,7 +70,7 @@ public interface Spawner extends BaseSpawner { * @param delay the new maximum spawn delay amount * @see #getMaxSpawnDelay() */ - public void setMaxSpawnDelay(int delay); + void setMaxSpawnDelay(int delay); /** * Get how many mobs attempt to spawn. @@ -76,27 +79,27 @@ public interface Spawner extends BaseSpawner { * * @return the current spawn count */ - public int getSpawnCount(); + int getSpawnCount(); /** * Set how many mobs attempt to spawn. * * @param spawnCount the new spawn count */ - public void setSpawnCount(int spawnCount); + void setSpawnCount(int spawnCount); /** - * Set the new maximum amount of similar entities that are allowed to be - * within spawning range of this spawner. + * Get the maximum number of similar entities that are allowed to be + * within the spawning range of this spawner. *
* If more than the maximum number of entities are within range, the spawner * will not spawn and try again with a new {@link #getDelay()}. *
- * Default value is 16. + * Default value is 6. * * @return the maximum number of nearby, similar, entities */ - public int getMaxNearbyEntities(); + int getMaxNearbyEntities(); /** * Set the maximum number of similar entities that are allowed to be within @@ -106,20 +109,19 @@ public interface Spawner extends BaseSpawner { * * @param maxNearbyEntities the maximum number of nearby, similar, entities */ - public void setMaxNearbyEntities(int maxNearbyEntities); + void setMaxNearbyEntities(int maxNearbyEntities); - // Paper start /** * Check if spawner is activated (a player is close enough) * * @return True if a player is close enough to activate it */ - public boolean isActivated(); + boolean isActivated(); /** * Resets the spawn delay timer within the min/max range */ - public void resetTimer(); + void resetTimer(); /** * Sets the {@link EntityType} to {@link EntityType#ITEM} and sets the data to the given @@ -128,9 +130,8 @@ public interface Spawner extends BaseSpawner { * {@link #setSpawnCount(int)} does not dictate the amount of items in the stack spawned, but rather how many * stacks should be spawned. * - * @param itemStack The item to spawn. Must not {@link org.bukkit.Material#isAir be air}. + * @param itemStack The item to spawn. Must not {@link ItemStack#isEmpty() be empty}. * @see #setSpawnedType(EntityType) */ - void setSpawnedItem(org.bukkit.inventory.@org.jetbrains.annotations.NotNull ItemStack itemStack); - // Paper end + void setSpawnedItem(ItemStack itemStack); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java index 9f20a8543b..74a39d826a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java @@ -8,7 +8,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; -import net.minecraft.core.RegistryAccess; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.InclusiveRange; import net.minecraft.util.ProblemReporter;