Skip to content

Fix NPE when general config section is missing in SlotDisplayEntity#36

Open
tommasov03 wants to merge 1 commit into
GeyserExtensionists:mainfrom
ScarletMC:fix/slot-display-null-config-npe
Open

Fix NPE when general config section is missing in SlotDisplayEntity#36
tommasov03 wants to merge 1 commit into
GeyserExtensionists:mainfrom
ScarletMC:fix/slot-display-null-config-npe

Conversation

@tommasov03

Copy link
Copy Markdown

Summary

  • Guard against config being null in SlotDisplayEntity / ItemDisplayEntity when getConfigurationSection("general") returns null, falling back to safe defaults instead of throwing.
  • Fixes a NullPointerException in SlotDisplayEntity.initializeMetadata() that crashed ClientboundAddEntityPacket translation on every display-entity spawn.

Root cause

getConfigurationSection("general") returns null when the general section is missing from config.yml (e.g. configs generated by an older plugin version — FileUtils.createFiles only creates the file if it doesn't exist yet, it never merges newly added keys into an existing config). SlotDisplayEntity then called config.getBoolean(...) unconditionally, causing an NPE on every entity spawn.

Changes

  • SlotDisplayEntity.java: null-guard the vanilla-scale / vanilla-scale-multiplier lookups in initializeMetadata(), setScale(), and applyScale().
  • ItemDisplayEntity.java: null-guard the hand lookup in updateMainHand() and the y-offset lookup in moveAbsoluteRaw(), matching the null-safe pattern already used elsewhere in the class.

Guard config.getBoolean/getDouble calls against a null config field
(getConfigurationSection("general") returns null when that section
is absent from config.yml, e.g. on outdated configs), matching the
null-safe pattern already used elsewhere in ItemDisplayEntity.
Copilot AI review requested due to automatic review settings July 17, 2026 09:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants