Optimised getByKey

This commit is contained in:
Auxilor 2020-12-19 18:20:15 +00:00
parent 316c16030d
commit 3828a53025

View File

@ -299,8 +299,10 @@ public class EcoEnchants {
* @return The matching {@link EcoEnchant}, or null if not found. * @return The matching {@link EcoEnchant}, or null if not found.
*/ */
public static EcoEnchant getByKey(NamespacedKey key) { public static EcoEnchant getByKey(NamespacedKey key) {
Optional<EcoEnchant> matching = getAll().stream().filter(enchant -> enchant.getKey().equals(key)).findFirst(); for (EcoEnchant ecoEnchant : getAll()) {
return matching.orElse(null); if(ecoEnchant.getKey().equals(key)) return ecoEnchant;
}
return null;
} }
/** /**