diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index a7879836c8..68546700fd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -377,7 +377,8 @@ public final class CraftMagicNumbers implements UnsafeValues { @Override public String getTranslationKey(EntityType entityType) { - return EntityTypes.byString(entityType.name()).map(EntityTypes::getDescriptionId).orElseThrow(); + Preconditions.checkArgument(entityType.getName() != null, "Invalid name of EntityType %s for translation key", entityType); + return EntityTypes.byString(entityType.getName()).map(EntityTypes::getDescriptionId).orElseThrow(); } @Override diff --git a/paper-server/src/test/java/org/bukkit/entity/EntityTypesTest.java b/paper-server/src/test/java/org/bukkit/entity/EntityTypesTest.java index 724e03c963..366509f17b 100644 --- a/paper-server/src/test/java/org/bukkit/entity/EntityTypesTest.java +++ b/paper-server/src/test/java/org/bukkit/entity/EntityTypesTest.java @@ -27,4 +27,14 @@ public class EntityTypesTest extends AbstractTestingBase { Assert.assertTrue("Unmapped bukkit entities " + allBukkit, allBukkit.isEmpty()); } + + @Test + public void testTranslationKey() { + for (EntityType entityType : EntityType.values()) { + // Currently EntityType#getTranslationKey has a validation for null name then for test skip this and check correct names. + if (entityType.getName() != null) { + Assert.assertNotNull("Nulllable translation key for " + entityType, entityType.getTranslationKey()); + } + } + } }