Skip to content

Conversation

@Warriorrrr
Copy link
Member

getEntitySpawnReason is supposed to be NotNull, but can return null if it's called on an entity at a bad time (i.e. in an event before the entity is fully added to the world). This PR makes it return DEFAULT in such cases to indicate that it's missing a spawn reason.

@Warriorrrr Warriorrrr requested a review from a team as a code owner December 6, 2025 10:57
@github-project-automation github-project-automation bot moved this to Awaiting review in Paper PR Queue Dec 6, 2025
public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason getEntitySpawnReason() {
return this.getHandle().spawnReason;
public CreatureSpawnEvent.SpawnReason getEntitySpawnReason() {
return Optional.ofNullable(this.getHandle().spawnReason).orElse(CreatureSpawnEvent.SpawnReason.DEFAULT);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you mean Objects.requireNonNullElse(spawnReason, DEFAULT).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Awaiting review

Development

Successfully merging this pull request may close these issues.

2 participants