From 3b2f2edb60bcbb8a266681a0ecc752c4f898c34a Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Mon, 2 Aug 2021 18:24:54 -0700 Subject: [PATCH] bukkit: Improve failure handling in EnchantmentArgument --- .../bukkit/parsers/EnchantmentArgument.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/EnchantmentArgument.java b/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/EnchantmentArgument.java index 5ef28d84..6c4db1e5 100644 --- a/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/EnchantmentArgument.java +++ b/cloud-minecraft/cloud-bukkit/src/main/java/cloud/commandframework/bukkit/parsers/EnchantmentArgument.java @@ -144,11 +144,15 @@ public class EnchantmentArgument extends CommandArgument { } 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);