From 3828a5302552ba922df3cc28b746052e6510aee8 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sat, 19 Dec 2020 18:20:15 +0000 Subject: [PATCH] Optimised getByKey --- .../com/willfp/ecoenchants/enchantments/EcoEnchants.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java index d0e51c1a..a4777413 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java @@ -299,8 +299,10 @@ public class EcoEnchants { * @return The matching {@link EcoEnchant}, or null if not found. */ public static EcoEnchant getByKey(NamespacedKey key) { - Optional matching = getAll().stream().filter(enchant -> enchant.getKey().equals(key)).findFirst(); - return matching.orElse(null); + for (EcoEnchant ecoEnchant : getAll()) { + if(ecoEnchant.getKey().equals(key)) return ecoEnchant; + } + return null; } /**