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;
|
final NamespacedKey key;
|
||||||
if (input.contains(":")) {
|
try {
|
||||||
final String[] splitInput = input.split(":");
|
if (input.contains(":")) {
|
||||||
key = new NamespacedKey(splitInput[0], splitInput[1]);
|
final String[] splitInput = input.split(":");
|
||||||
} else {
|
key = new NamespacedKey(splitInput[0], splitInput[1]);
|
||||||
key = NamespacedKey.minecraft(input);
|
} else {
|
||||||
|
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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue