/** * Creates a translatable component by applying configuration from {@code consumer}. * * @param consumer the builder configurator * @return the translatable component */ public static TranslatableComponent make(final @NonNull Consumer<Builder> consumer) { final Builder builder = builder(); consumer.accept(builder); return builder.build(); }
/** * Creates a translatable component by applying configuration from {@code consumer}. * * @param consumer the builder configurator * @return the translatable component */ public static TranslatableComponent make(final @NonNull Consumer<Builder> consumer) { final Builder builder = builder(); consumer.accept(builder); return builder.build(); }
/** * Creates a translatable component by applying configuration from {@code consumer}. * * @param consumer the builder configurator * @return the translatable component */ public static TranslatableComponent make(final @NonNull Consumer<Builder> consumer) { final Builder builder = builder(); consumer.accept(builder); return builder.build(); }
/** * Creates a translatable component with a translation key. * * @param key the translation key * @return the translatable component */ public static TranslatableComponent of(final @NonNull String key) { return builder(key).build(); }
/** * Creates a translatable component with a translation key. * * @param key the translation key * @return the translatable component */ public static TranslatableComponent of(final @NonNull String key) { return builder(key).build(); }
/** * Creates a translatable component with a translation key. * * @param key the translation key * @return the translatable component */ public static TranslatableComponent of(final @NonNull String key) { return builder(key).build(); }
/** * Creates a translatable component by applying configuration from {@code consumer}. * * @param key the translation key * @param consumer the builder configurator * @return the translatable component */ public static TranslatableComponent make(final @NonNull String key, final @NonNull Consumer<Builder> consumer) { final Builder builder = builder(key); consumer.accept(builder); return builder.build(); }
/** * Creates a translatable component by applying configuration from {@code consumer}. * * @param key the translation key * @param consumer the builder configurator * @return the translatable component */ public static TranslatableComponent make(final @NonNull String key, final @NonNull Consumer<Builder> consumer) { final Builder builder = builder(key); consumer.accept(builder); return builder.build(); }
/** * Creates a translatable component by applying configuration from {@code consumer}. * * @param key the translation key * @param consumer the builder configurator * @return the translatable component */ public static TranslatableComponent make(final @NonNull String key, final @NonNull Consumer<Builder> consumer) { final Builder builder = builder(key); consumer.accept(builder); return builder.build(); }
/** * Creates a translatable component by applying configuration from {@code consumer}. * * @param key the translation key * @param args the translation arguments * @param consumer the builder configurator * @return the translatable component */ public static TranslatableComponent make(final @NonNull String key, final @NonNull List<Component> args, final @NonNull Consumer<Builder> consumer) { final Builder builder = builder(key).args(args); consumer.accept(builder); return builder.build(); }
/** * Creates a translatable component by applying configuration from {@code consumer}. * * @param key the translation key * @param args the translation arguments * @param consumer the builder configurator * @return the translatable component */ public static TranslatableComponent make(final @NonNull String key, final @NonNull List<Component> args, final @NonNull Consumer<Builder> consumer) { final Builder builder = builder(key).args(args); consumer.accept(builder); return builder.build(); }
/** * Creates a translatable component by applying configuration from {@code consumer}. * * @param key the translation key * @param args the translation arguments * @param consumer the builder configurator * @return the translatable component */ public static TranslatableComponent make(final @NonNull String key, final @NonNull List<Component> args, final @NonNull Consumer<Builder> consumer) { final Builder builder = builder(key).args(args); consumer.accept(builder); return builder.build(); }
/** * Creates a translatable component with a translation key. * * @param key the translation key * @param color the color * @return the translatable component */ public static TranslatableComponent of(final @NonNull String key, final @Nullable TextColor color) { return builder(key) .color(color) .build(); }
/** * Creates a translatable component with a translation key. * * @param key the translation key * @param color the color * @return the translatable component */ public static TranslatableComponent of(final @NonNull String key, final @Nullable TextColor color) { return builder(key) .color(color) .build(); }
/** * Creates a translatable component with a translation key. * * @param key the translation key * @param color the color * @return the translatable component */ public static TranslatableComponent of(final @NonNull String key, final @Nullable TextColor color) { return builder(key) .color(color) .build(); }
/** * Creates a translatable component with a translation key. * * @param key the translation key * @param color the color * @param decorations the decorations * @return the translatable component */ public static TranslatableComponent of(final @NonNull String key, final @Nullable TextColor color, final @NonNull Set<TextDecoration> decorations) { return builder(key) .color(color) .decorations(decorations, true) .build(); }
/** * Creates a translatable component with a translation key. * * @param key the translation key * @param color the color * @param decorations the decorations * @return the translatable component */ public static TranslatableComponent of(final @NonNull String key, final @Nullable TextColor color, final @NonNull Set<TextDecoration> decorations) { return builder(key) .color(color) .decorations(decorations, true) .build(); }
/** * Creates a translatable component with a translation key. * * @param key the translation key * @param color the color * @param decorations the decorations * @return the translatable component */ public static TranslatableComponent of(final @NonNull String key, final @Nullable TextColor color, final @NonNull Set<TextDecoration> decorations) { return builder(key) .color(color) .decorations(decorations, true) .build(); }
@Test void testContains() { final Component child = TranslatableComponent.of("multiplayer.player.left"); final Component component = TranslatableComponent.builder() .key("multiplayer.player.left") .append(child) .build(); assertTrue(component.contains(child)); }
@Test void testDeserializeTranslatable() { assertEquals(TranslatableComponent.of("multiplayer.player.left"), GsonComponentSerializer.INSTANCE.deserialize("{\"translate\":\"multiplayer.player.left\"}")); assertEquals(TranslatableComponent.builder("multiplayer.player.left") .args(TextComponent.of("kashike")) .build(), GsonComponentSerializer.INSTANCE.deserialize("{\"translate\":\"multiplayer.player.left\",\"with\":[{\"text\":\"kashike\"}]}")); }