From 9947afe18bf129080091e7344b46c24c6630fec3 Mon Sep 17 00:00:00 2001 From: TheMode Date: Thu, 20 Jan 2022 21:04:14 +0100 Subject: [PATCH] Ensure that all meta are registered Signed-off-by: TheMode --- .../minestom/server/entity/EntityTypeImpl.java | 3 ++- .../minestom/server/entity/EntityMetaTest.java | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/test/java/net/minestom/server/entity/EntityMetaTest.java diff --git a/src/main/java/net/minestom/server/entity/EntityTypeImpl.java b/src/main/java/net/minestom/server/entity/EntityTypeImpl.java index 0aa410d0a..d2b7e0337 100644 --- a/src/main/java/net/minestom/server/entity/EntityTypeImpl.java +++ b/src/main/java/net/minestom/server/entity/EntityTypeImpl.java @@ -45,7 +45,7 @@ import java.util.function.BiFunction; record EntityTypeImpl(Registry.EntityEntry registry) implements EntityType { private static final Registry.Container CONTAINER = Registry.createContainer(Registry.Resource.ENTITIES, (namespace, object) -> new EntityTypeImpl(Registry.entity(namespace, object, null))); - private static final Map> ENTITY_META_SUPPLIER = createMetaMap(); + static final Map> ENTITY_META_SUPPLIER = createMetaMap(); static EntityType get(@NotNull String namespace) { return CONTAINER.get(namespace); @@ -75,6 +75,7 @@ record EntityTypeImpl(Registry.EntityEntry registry) implements EntityType { supplier.put("minecraft:axolotl", AxolotlMeta::new); supplier.put("minecraft:bat", BatMeta::new); supplier.put("minecraft:bee", BeeMeta::new); + supplier.put("minecraft:blaze", BlazeMeta::new); supplier.put("minecraft:boat", BoatMeta::new); supplier.put("minecraft:cat", CatMeta::new); supplier.put("minecraft:cave_spider", CaveSpiderMeta::new); diff --git a/src/test/java/net/minestom/server/entity/EntityMetaTest.java b/src/test/java/net/minestom/server/entity/EntityMetaTest.java new file mode 100644 index 000000000..652501001 --- /dev/null +++ b/src/test/java/net/minestom/server/entity/EntityMetaTest.java @@ -0,0 +1,17 @@ +package net.minestom.server.entity; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +public class EntityMetaTest { + + @Test + public void ensureRegistration() throws IllegalAccessException { + var fields = EntityTypes.class.getDeclaredFields(); + for (var field : fields) { + EntityType entityType = (EntityType) field.get(this); + assertNotNull(EntityTypeImpl.ENTITY_META_SUPPLIER.get(entityType.name()), "Meta for " + entityType.name() + " is null"); + } + } +}