From d9537ee9dfb8d881d0847f1af2a755a41e32f067 Mon Sep 17 00:00:00 2001 From: Pierre Maurice Schwang Date: Mon, 12 Feb 2024 18:32:27 +0100 Subject: [PATCH] Suppress errors due to failed getEntitySpawnReason implementation (#4334) fix: suppress errors due to failed getEntitySpawnReason implementation --- .../src/main/java/com/plotsquared/bukkit/BukkitPlatform.java | 3 ++- .../com/plotsquared/bukkit/listener/EntitySpawnListener.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java index 6f27e1b10..8aa3fb7c0 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java @@ -779,7 +779,8 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl Iterator iterator = entities.iterator(); while (iterator.hasNext()) { Entity entity = iterator.next(); - if (PaperLib.isPaper() && "CUSTOM".equals(entity.getEntitySpawnReason().name())) { + //noinspection ConstantValue - getEntitySpawnReason annotated as NotNull, but is not NotNull. lol. + if (PaperLib.isPaper() && entity.getEntitySpawnReason() != null && "CUSTOM".equals(entity.getEntitySpawnReason().name())) { continue; } // Fallback for Spigot not having Entity#getEntitySpawnReason diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java index fc2f3a275..f1f05b653 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntitySpawnListener.java @@ -124,7 +124,8 @@ public class EntitySpawnListener implements Listener { return; } if (PaperLib.isPaper()) { - if (area.isSpawnCustom() && "CUSTOM".equals(entity.getEntitySpawnReason().name())) { + //noinspection ConstantValue - getEntitySpawnReason annotated as NotNull, but is not NotNull. lol. + if (area.isSpawnCustom() && entity.getEntitySpawnReason() != null && "CUSTOM".equals(entity.getEntitySpawnReason().name())) { return; } }