EnchantUtils do not get enchant by null key

This commit is contained in:
Alexander
2021-05-27 15:12:57 +01:00
parent 8c7ff2670f
commit 0cd47dc067

View File

@@ -140,9 +140,13 @@ public final class EnchantUtils {
if (Strings.isNullOrEmpty(value)) {
return null;
}
Enchantment enchantment = Enchantment.getByKey(KeyedUtils.fromString(value));
if (enchantment != null) {
return enchantment;
Enchantment enchantment;
final var enchantmentKey = KeyedUtils.fromString(value);
if (enchantmentKey != null) {
enchantment = Enchantment.getByKey(enchantmentKey);
if (enchantment != null) {
return enchantment;
}
}
enchantment = Enchantment.getByName(value.toUpperCase()); // deprecated
if (enchantment != null) {