SPIGOT-7267: Fix EntityType#getTranslationKey() and add unit test

By: Doc <nachito94@msn.com>
This commit is contained in:
CraftBukkit/Spigot
2023-02-20 19:35:39 +11:00
parent b83c3d9c17
commit 412e157d39
2 changed files with 12 additions and 1 deletions

View File

@@ -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