EnchantmentType implements WordType<Enchantment> { @Override public Enchantment parse(StringReader reader) throws CommandSyntaxException { var name = reader.readUnquotedString().toLowerCase(); var enchantment = ENCHANTMENTS.get(name); if (enchantment == null) { throw EXCEPTION.createWithContext(reader, name); } return enchantment; }  @Override Enchantment parse(StringReader reader); @Override CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder); @Override List<String> getExamples();  }
@Test void parse() throws CommandSyntaxException { Enchantment enchantment = mock(Enchantment.class); EnchantmentType.ENCHANTMENTS.put("channeling", enchantment); assertEquals(enchantment, type.parse(new StringReader("CHANNELING"))); }
@Test void parse_throws_exception() throws CommandSyntaxException { assertEquals( "Unknown enchantment: invalid", assertThrows(CommandSyntaxException.class, () -> type.parse(new StringReader("invalid"))).getRawMessage().toString() ); }