use of net.kyori.adventure.text.Component.text in project adventure by KyoriPowered.
the class ComponentCompactionBenchmark method prepare.
@Setup(Level.Trial)
public void prepare() {
this.alreadyCompactedInput = Component.text().content("Hello World!").color(NamedTextColor.RED).append(Component.text(" aaaa", style(b -> b.color(NamedTextColor.BLUE).font(Key.key("uniform"))))).build();
final Style simpleScenarioStyle = style().color(NamedTextColor.AQUA).font(key("uniform")).decorate(TextDecoration.BOLD, TextDecoration.ITALIC).build();
this.simpleScenarioInput = text().content("Hello ").style(simpleScenarioStyle).append(text("World!", style(TextDecoration.BOLD).font(key("uniform")))).build();
this.moreComplexInput = text().content("Hello ").style(style(NamedTextColor.RED, TextDecoration.BOLD, TextDecoration.OBFUSCATED)).append(text("World! ")).append(text("What a ", NamedTextColor.RED)).append(text(c -> c.content("beautiful day ").color(NamedTextColor.BLUE).append(text("to create ", style(TextDecoration.ITALIC))).append(text("a PR ", style(TextDecoration.BOLD))).append(text("on Adventure!")))).build();
}
use of net.kyori.adventure.text.Component.text in project adventure by KyoriPowered.
the class TagResolverTest method testSingleAndResolversCombine.
@Test
void testSingleAndResolversCombine() {
final List<TagResolver> placeholders = Arrays.asList(Placeholder.component("foo", Component.text("fizz")), Placeholder.parsed("overlapping", "from list"));
final TagResolver.WithoutArguments resolver = key -> {
switch(key) {
case "one":
return Tag.preProcessParsed("fish");
case "overlapping":
return Tag.preProcessParsed("from resolver");
default:
return null;
}
};
final TagResolver built = TagResolver.builder().resolvers(placeholders).resolver(resolver).build();
// from placeholders only
assertEquals(Component.text("fizz"), ((Inserting) resolveForTest(built, "foo")).value());
// from resolver only
assertEquals("fish", ((PreProcess) resolveForTest(built, "one")).value());
// shared, resolver takes priority
assertEquals("from resolver", ((PreProcess) resolveForTest(built, "overlapping")).value());
}
Aggregations