SPIGOT-7267: Fix EntityType#getTranslationKey() and add unit test
This commit is contained in:
parent
086d8dc8ac
commit
4a929b5d66
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user