From 56ce7afee1a2c67921d0e525724590ceacdb5d9f Mon Sep 17 00:00:00 2001 From: Tommaso <110355739+tommasov03@users.noreply.github.com> Date: Fri, 17 Jul 2026 09:04:01 +0000 Subject: [PATCH] Fix NPE when general config section is missing in SlotDisplayEntity 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. --- .../geyserdisplayentity/entity/ItemDisplayEntity.java | 4 ++-- .../geyserdisplayentity/entity/SlotDisplayEntity.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/geyserextensionists/geyserdisplayentity/entity/ItemDisplayEntity.java b/src/main/java/me/geyserextensionists/geyserdisplayentity/entity/ItemDisplayEntity.java index 07b177b..995db97 100644 --- a/src/main/java/me/geyserextensionists/geyserdisplayentity/entity/ItemDisplayEntity.java +++ b/src/main/java/me/geyserextensionists/geyserdisplayentity/entity/ItemDisplayEntity.java @@ -219,7 +219,7 @@ public void updateMainHand(GeyserSession session) { ItemData helmet = ItemData.AIR; // TODO ItemData chest = item; - if (custom && !config.getBoolean("hand")) { + if (custom && !(config != null && config.getBoolean("hand"))) { MobArmorEquipmentPacket armorEquipmentPacket = new MobArmorEquipmentPacket(); armorEquipmentPacket.setRuntimeEntityId(geyserId); armorEquipmentPacket.setHelmet(helmet); @@ -290,7 +290,7 @@ private static int getColor(int argb) { @Override public void moveAbsoluteRaw(Vector3f position, float yaw, float pitch, float headYaw, boolean isOnGround, boolean teleported) { - double yOffset = config.getDouble("y-offset"); + double yOffset = config != null ? config.getDouble("y-offset") : -0.5; setPosition(position); setYaw(yaw); setPitch(pitch); diff --git a/src/main/java/me/geyserextensionists/geyserdisplayentity/entity/SlotDisplayEntity.java b/src/main/java/me/geyserextensionists/geyserdisplayentity/entity/SlotDisplayEntity.java index 99670fb..e142d98 100644 --- a/src/main/java/me/geyserextensionists/geyserdisplayentity/entity/SlotDisplayEntity.java +++ b/src/main/java/me/geyserextensionists/geyserdisplayentity/entity/SlotDisplayEntity.java @@ -67,7 +67,7 @@ public void initializeMetadata() { propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:s_y"), MAX_VALUE, MIN_VALUE, 0F), scale.getY()); propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:s_z"), MAX_VALUE, MIN_VALUE, 0F), scale.getZ()); - if (config.getBoolean("vanilla-scale")) applyScale(); + if (config != null && config.getBoolean("vanilla-scale")) applyScale(); displayRotation = Vector3f.from(0, 0, 0); displayTranslation = Vector3f.from(0, 0, 0); @@ -127,7 +127,7 @@ protected void pushRotationProperties() { public void setScale(EntityMetadata entityMetadata) { this.scale = entityMetadata.getValue(); - if (config.getBoolean("vanilla-scale")) applyScale(); + if (config != null && config.getBoolean("vanilla-scale")) applyScale(); propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:s_x"), MAX_VALUE, MIN_VALUE, 0F), scale.getX()); propertyManager.addProperty(new FloatProperty(Identifier.of("geyser:s_y"), MAX_VALUE, MIN_VALUE, 0F), scale.getY()); @@ -137,7 +137,7 @@ public void setScale(EntityMetadata entityMetadata) { protected void applyScale() { Vector3f vector3f = this.scale; float scale = (vector3f.getX() + vector3f.getY() + vector3f.getZ()) / 3; - if (config.getBoolean("vanilla-scale")) scale *= (float) config.getDouble("vanilla-scale-multiplier"); + if (config != null && config.getBoolean("vanilla-scale")) scale *= (float) config.getDouble("vanilla-scale-multiplier"); this.metadata.put(EntityDataTypes.SCALE, scale); }