mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-08 03:22:19 +01:00
SPIGOT-7267: Fix EntityType#getTranslationKey() and add unit test
By: Doc <nachito94@msn.com>
This commit is contained in:
parent
b83c3d9c17
commit
412e157d39
2 changed files with 12 additions and 1 deletions
|
@ -377,7 +377,8 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTranslationKey(EntityType entityType) {
|
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
|
@Override
|
||||||
|
|
|
@ -27,4 +27,14 @@ public class EntityTypesTest extends AbstractTestingBase {
|
||||||
|
|
||||||
Assert.assertTrue("Unmapped bukkit entities " + allBukkit, allBukkit.isEmpty());
|
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…
Reference in a new issue