From 1afa22d5cf4406eddd2b7fcc2d666af893bf288b Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Fri, 13 Aug 2021 13:42:35 -0400 Subject: [PATCH] Fix NPE with area effect cloud particles --- .../org/geysermc/connector/utils/EffectUtils.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/utils/EffectUtils.java b/connector/src/main/java/org/geysermc/connector/utils/EffectUtils.java index 8d69fa691..b79476e9c 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/EffectUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/EffectUtils.java @@ -27,9 +27,11 @@ package org.geysermc.connector.utils; import com.github.steveice10.mc.protocol.data.game.world.particle.ParticleType; import com.nukkitx.protocol.bedrock.data.LevelEventType; -import lombok.NonNull; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.registry.Registries; +import org.geysermc.connector.registry.type.ParticleMapping; + +import javax.annotation.Nonnull; /** * Util for particles and effects. @@ -42,8 +44,13 @@ public class EffectUtils { * @param type the Java particle to search for * @return the Bedrock integer ID of the particle, or -1 if it does not exist */ - public static int getParticleId(GeyserSession session, @NonNull ParticleType type) { - LevelEventType levelEventType = Registries.PARTICLES.get(type).getLevelEventType(); + public static int getParticleId(GeyserSession session, @Nonnull ParticleType type) { + ParticleMapping mapping = Registries.PARTICLES.get(type); + if (mapping == null) { + return -1; + } + + LevelEventType levelEventType = mapping.getLevelEventType(); if (levelEventType == null) { return -1; }