From 23e4eb9e8d31808f26759020653c88fa9427df40 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Mon, 14 Jun 2021 14:16:26 +0100 Subject: [PATCH] Slight optimisations --- .../willfp/ecoarmor/sets/meta/ArmorSlot.java | 45 +++++++------------ 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/meta/ArmorSlot.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/meta/ArmorSlot.java index 0efa279..16e0bff 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/meta/ArmorSlot.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/meta/ArmorSlot.java @@ -59,21 +59,14 @@ public enum ArmorSlot { String[] split = material.name().toLowerCase().split("_"); String name = split[split.length - 1]; - switch (name) { - case "helmet": - case "head": - return HELMET; - case "chestplate": - return CHESTPLATE; - case "elytra": - return ELYTRA; - case "leggings": - return LEGGINGS; - case "boots": - return BOOTS; - default: - return null; - } + return switch (name) { + case "helmet", "head" -> HELMET; + case "chestplate" -> CHESTPLATE; + case "elytra" -> ELYTRA; + case "leggings" -> LEGGINGS; + case "boots" -> BOOTS; + default -> null; + }; } /** @@ -84,19 +77,13 @@ public enum ArmorSlot { */ @Nullable public static ArmorSlot getSlot(@NotNull final String name) { - switch (name.toLowerCase()) { - case "helmet": - return HELMET; - case "chestplate": - return CHESTPLATE; - case "elytra": - return ELYTRA; - case "leggings": - return LEGGINGS; - case "boots": - return BOOTS; - default: - return null; - } + return switch (name.toLowerCase()) { + case "helmet" -> HELMET; + case "chestplate" -> CHESTPLATE; + case "elytra" -> ELYTRA; + case "leggings" -> LEGGINGS; + case "boots" -> BOOTS; + default -> null; + }; } }