bukkit: Improve failure handling in EnchantmentArgument

This commit is contained in:
Jason Penilla 2021-08-02 18:24:54 -07:00 committed by Jason
parent 9c85db386f
commit 3b2f2edb60

View file

@ -144,12 +144,16 @@ public class EnchantmentArgument<C> extends CommandArgument<C, Enchantment> {
} }
final NamespacedKey key; final NamespacedKey key;
try {
if (input.contains(":")) { if (input.contains(":")) {
final String[] splitInput = input.split(":"); final String[] splitInput = input.split(":");
key = new NamespacedKey(splitInput[0], splitInput[1]); key = new NamespacedKey(splitInput[0], splitInput[1]);
} else { } else {
key = NamespacedKey.minecraft(input); key = NamespacedKey.minecraft(input);
} }
} catch (final Exception ex) {
return ArgumentParseResult.failure(new EnchantmentParseException(input, commandContext));
}
final Enchantment enchantment = Enchantment.getByKey(key); final Enchantment enchantment = Enchantment.getByKey(key);
if (enchantment == null) { if (enchantment == null) {