use of net.kyori.adventure.text.minimessage.tag.resolver.TagResolver in project MiniPlaceholders by 4drian3d.
the class PlaceholderBenchmark method singleBench.
@Benchmark
public void singleBench() {
Expansion.builder("single").globalPlaceholder("servername", (queue, ctx) -> Tag.selfClosingInserting(Component.text("Peruviankkit"))).build().register();
TagResolver resolvers = MiniPlaceholders.getGlobalPlaceholders();
MiniMessage.miniMessage().deserialize("Server name: <single-servername>", resolvers);
}
use of net.kyori.adventure.text.minimessage.tag.resolver.TagResolver in project adventure by KyoriPowered.
the class MiniMessageParserTest method invalidPreprocessTagNames.
@Test
void invalidPreprocessTagNames() {
final String input = "Some<##>of<>these<tag>are<3 >tags";
final Component expected = Component.text("Some<##>of<>these(meow)are<3 >tags");
final TagResolver alwaysMatchingResolver = new TagResolver() {
@Override
public Tag resolve(@NotNull final String name, @NotNull final ArgumentQueue arguments, @NotNull final Context ctx) throws ParsingException {
return Tag.preProcessParsed("(meow)");
}
@Override
public boolean has(@NotNull final String name) {
return true;
}
};
assertParsedEquals(expected, input, alwaysMatchingResolver);
}
use of net.kyori.adventure.text.minimessage.tag.resolver.TagResolver in project adventure by KyoriPowered.
the class MiniMessageParserTest method testTreeOutput.
@Test
void testTreeOutput() {
final String input = "<red> RED <blue> <name> <click:open_url:https://github.com> good <action> </click>";
final TagResolver resolver = TagResolver.resolver(Placeholder.parsed("name", "you"), Placeholder.component("action", Component.text("click")));
final Node tree = MiniMessage.miniMessage().deserializeToTree(input, resolver);
final String expected = "Node {\n" + " TagNode('red') {\n" + " TextNode(' RED ')\n" + " TagNode('blue') {\n" + " TextNode(' you ')\n" + " TagNode('click', 'open_url', 'https://github.com') {\n" + " TextNode(' good ')\n" + " TagNode('action') {\n" + " }\n" + " TextNode(' ')\n" + " }\n" + " }\n" + " }\n" + "}\n";
assertEquals(expected, tree.toString());
}
use of net.kyori.adventure.text.minimessage.tag.resolver.TagResolver in project adventure by KyoriPowered.
the class MiniMessageTest method testCustomRegistryBuilder.
@Test
void testCustomRegistryBuilder() {
final Component expected = empty().color(GREEN).append(text("<bold>")).append(text("TEST"));
final String input = "<green><bold><test>";
final TagResolver registry = TagResolver.builder().resolver(StandardTags.color()).build();
final MiniMessage miniMessage = MiniMessage.builder().tags(registry).build();
this.assertParsedEquals(miniMessage, expected, input, component("test", text("TEST")));
}
use of net.kyori.adventure.text.minimessage.tag.resolver.TagResolver in project adventure by KyoriPowered.
the class MiniMessageTest method testPlaceholderComponentMixed.
@Test
void testPlaceholderComponentMixed() {
final Component expected = empty().color(GREEN).decorate(BOLD).append(text("TEST", style(RED, UNDERLINED))).append(text("Test2"));
final String input = "<green><bold><test><test2>";
final MiniMessage miniMessage = MiniMessage.miniMessage();
final TagResolver t1 = component("test", text("TEST", style(RED, UNDERLINED)));
final TagResolver t2 = Placeholder.parsed("test2", "Test2");
this.assertParsedEquals(miniMessage, expected, input, t1, t2);
}
Aggregations