Migrate 'EntityUtil#capNumeral' to an enhanced switch (#4195)

* Migrate 'EntityUtil#capNumeral' to an enhanced switch

* Apply feedback
This commit is contained in:
Alexander Brandes 2023-10-04 11:34:50 +02:00 committed by GitHub
parent 5f7bb784f0
commit fc783574a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 22 deletions

View File

@ -42,28 +42,14 @@ public class EntityUtil {
}
private static int capNumeral(final @NonNull String flagName) {
int i;
switch (flagName) {
case "mob-cap":
i = CAP_MOB;
break;
case "hostile-cap":
i = CAP_MONSTER;
break;
case "animal-cap":
i = CAP_ANIMAL;
break;
case "vehicle-cap":
i = CAP_VEHICLE;
break;
case "misc-cap":
i = CAP_MISC;
break;
case "entity-cap":
default:
i = CAP_ENTITY;
}
return i;
return switch (flagName) {
case "mob-cap" -> CAP_MOB;
case "hostile-cap" -> CAP_MONSTER;
case "animal-cap" -> CAP_ANIMAL;
case "vehicle-cap" -> CAP_VEHICLE;
case "misc-cap" -> CAP_MISC;
default -> CAP_ENTITY;
};
}
@SuppressWarnings("unchecked")