mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-24 17:12:03 +01:00
Wrap Enchantment.getByKey in try/catch for older versions
Should address #2351.
This commit is contained in:
parent
97cc3d0066
commit
1388755d2a
@ -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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user