mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-26 02:57:37 +01:00
Ensure that all meta are registered
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
7f9f33d462
commit
9947afe18b
@ -45,7 +45,7 @@ import java.util.function.BiFunction;
|
|||||||
record EntityTypeImpl(Registry.EntityEntry registry) implements EntityType {
|
record EntityTypeImpl(Registry.EntityEntry registry) implements EntityType {
|
||||||
private static final Registry.Container<EntityType> CONTAINER = Registry.createContainer(Registry.Resource.ENTITIES,
|
private static final Registry.Container<EntityType> CONTAINER = Registry.createContainer(Registry.Resource.ENTITIES,
|
||||||
(namespace, object) -> new EntityTypeImpl(Registry.entity(namespace, object, null)));
|
(namespace, object) -> new EntityTypeImpl(Registry.entity(namespace, object, null)));
|
||||||
private static final Map<String, BiFunction<Entity, Metadata, EntityMeta>> ENTITY_META_SUPPLIER = createMetaMap();
|
static final Map<String, BiFunction<Entity, Metadata, EntityMeta>> ENTITY_META_SUPPLIER = createMetaMap();
|
||||||
|
|
||||||
static EntityType get(@NotNull String namespace) {
|
static EntityType get(@NotNull String namespace) {
|
||||||
return CONTAINER.get(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:axolotl", AxolotlMeta::new);
|
||||||
supplier.put("minecraft:bat", BatMeta::new);
|
supplier.put("minecraft:bat", BatMeta::new);
|
||||||
supplier.put("minecraft:bee", BeeMeta::new);
|
supplier.put("minecraft:bee", BeeMeta::new);
|
||||||
|
supplier.put("minecraft:blaze", BlazeMeta::new);
|
||||||
supplier.put("minecraft:boat", BoatMeta::new);
|
supplier.put("minecraft:boat", BoatMeta::new);
|
||||||
supplier.put("minecraft:cat", CatMeta::new);
|
supplier.put("minecraft:cat", CatMeta::new);
|
||||||
supplier.put("minecraft:cave_spider", CaveSpiderMeta::new);
|
supplier.put("minecraft:cave_spider", CaveSpiderMeta::new);
|
||||||
|
17
src/test/java/net/minestom/server/entity/EntityMetaTest.java
Normal file
17
src/test/java/net/minestom/server/entity/EntityMetaTest.java
Normal file
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user