From fc783574a346ca805ca6fbb22148c16d3cfb6e44 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Wed, 4 Oct 2023 11:34:50 +0200 Subject: [PATCH] Migrate 'EntityUtil#capNumeral' to an enhanced switch (#4195) * Migrate 'EntityUtil#capNumeral' to an enhanced switch * Apply feedback --- .../com/plotsquared/core/util/EntityUtil.java | 30 +++++-------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/util/EntityUtil.java b/Core/src/main/java/com/plotsquared/core/util/EntityUtil.java index db2a3fc90..12cd40b11 100644 --- a/Core/src/main/java/com/plotsquared/core/util/EntityUtil.java +++ b/Core/src/main/java/com/plotsquared/core/util/EntityUtil.java @@ -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")