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.
*/
public static EcoEnchant getByKey(NamespacedKey key) {
Optional<EcoEnchant> 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;
}
/**