bukkit: Improve failure handling in EnchantmentArgument
This commit is contained in:
parent
9c85db386f
commit
3b2f2edb60
1 changed files with 9 additions and 5 deletions
|
|
@ -144,11 +144,15 @@ public class EnchantmentArgument<C> extends CommandArgument<C, Enchantment> {
|
|||
}
|
||||
|
||||
final NamespacedKey key;
|
||||
if (input.contains(":")) {
|
||||
final String[] splitInput = input.split(":");
|
||||
key = new NamespacedKey(splitInput[0], splitInput[1]);
|
||||
} else {
|
||||
key = NamespacedKey.minecraft(input);
|
||||
try {
|
||||
if (input.contains(":")) {
|
||||
final String[] splitInput = input.split(":");
|
||||
key = new NamespacedKey(splitInput[0], splitInput[1]);
|
||||
} else {
|
||||
key = NamespacedKey.minecraft(input);
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
return ArgumentParseResult.failure(new EnchantmentParseException(input, commandContext));
|
||||
}
|
||||
|
||||
final Enchantment enchantment = Enchantment.getByKey(key);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue