From 498f7653d3ed4334733b48bee203defd33b6b2b1 Mon Sep 17 00:00:00 2001 From: rtm516 Date: Thu, 28 Jan 2021 16:33:26 +0000 Subject: [PATCH] Fix NPE when link entity not found and use non-deprecated constructor (#1706) * Fix NPE when link entity not found and use non-deprecated constructor * Extract method call to variable * Update PlayerEntity.java * Fix indentation --- .../org/geysermc/connector/entity/player/PlayerEntity.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/entity/player/PlayerEntity.java b/connector/src/main/java/org/geysermc/connector/entity/player/PlayerEntity.java index fc7b867bb..5cef3252a 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/player/PlayerEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/player/PlayerEntity.java @@ -103,7 +103,10 @@ public class PlayerEntity extends LivingEntity { long linkedEntityId = session.getEntityCache().getCachedPlayerEntityLink(entityId); if (linkedEntityId != -1) { - addPlayerPacket.getEntityLinks().add(new EntityLinkData(session.getEntityCache().getEntityByJavaId(linkedEntityId).getGeyserId(), geyserId, EntityLinkData.Type.RIDER, false)); + Entity linkedEntity = session.getEntityCache().getEntityByJavaId(linkedEntityId); + if (linkedEntity != null) { + addPlayerPacket.getEntityLinks().add(new EntityLinkData(linkedEntity.getGeyserId(), geyserId, EntityLinkData.Type.RIDER, false, false)); + } } valid = true;