Wrap Enchantment.getByKey in try/catch for older versions

Should address #2351.
This commit is contained in:
md678685 2019-01-05 15:17:40 +00:00
parent 97cc3d0066
commit 1388755d2a

View File

@ -234,7 +234,12 @@ public class Enchantments {
}
public static Enchantment getByName(String name) {
Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(name.toLowerCase()));
Enchantment enchantment = null;
try {
// 1.13+ only
enchantment = Enchantment.getByKey(NamespacedKey.minecraft(name.toLowerCase()));
} catch (NoSuchMethodError ignored) {}
if (enchantment == null) {
enchantment = Enchantment.getByName(name.toUpperCase());
}