/** * Creates a keybind component with content, and optional color. * * @param keybind the keybind * @param color the color * @return the keybind component */ public static KeybindComponent of(final @NonNull String keybind, final @Nullable TextColor color) { return of(keybind, color, Collections.emptySet()); }
/** * Creates a keybind component with content, and optional color. * * @param keybind the keybind * @param color the color * @return the keybind component */ public static KeybindComponent of(final @NonNull String keybind, final @Nullable TextColor color) { return of(keybind, color, Collections.emptySet()); }
/** * Creates a keybind component with content, and optional color. * * @param keybind the keybind * @param color the color * @return the keybind component */ public static KeybindComponent of(final @NonNull String keybind, final @Nullable TextColor color) { return of(keybind, color, Collections.emptySet()); }
@Test void testDeserializeKeybind() { assertEquals(KeybindComponent.of("key.jump"), GsonComponentSerializer.INSTANCE.deserialize("{\"keybind\":\"key.jump\"}")); }
@Test void testRebuildWithNoChanges() { final KeybindComponent component = KeybindComponent.of("keybind.jump"); assertEquals(component, component.toBuilder().build()); } }
@Test void testKeybind() { final KeybindComponent c0 = KeybindComponent.of("key.jump"); final KeybindComponent c1 = c0.keybind("key.up"); assertEquals("key.jump", c0.keybind()); assertEquals("key.up", c1.keybind()); }
@Test void testOf_color() { final KeybindComponent component = KeybindComponent.of("key.jump", TextColor.GREEN); assertEquals("key.jump", component.keybind()); assertEquals(TextColor.GREEN, component.color()); for(final TextDecoration decoration : TextDecoration.values()) { assertEquals(TextDecoration.State.NOT_SET, component.decoration(decoration)); } }
@Test void testOf() { final KeybindComponent component = KeybindComponent.of("key.jump"); assertEquals("key.jump", component.keybind()); assertNull(component.color()); for(final TextDecoration decoration : TextDecoration.values()) { assertEquals(TextDecoration.State.NOT_SET, component.decoration(decoration)); } }
@Test void testOf_color_decorations() { final KeybindComponent component = KeybindComponent.of("key.jump", TextColor.GREEN, ImmutableSet.of(TextDecoration.BOLD)); assertEquals("key.jump", component.keybind()); assertEquals(TextColor.GREEN, component.color()); assertEquals(TextDecoration.State.NOT_SET, component.decoration(TextDecoration.OBFUSCATED)); assertEquals(TextDecoration.State.TRUE, component.decoration(TextDecoration.BOLD)); assertEquals(TextDecoration.State.NOT_SET, component.decoration(TextDecoration.STRIKETHROUGH)); assertEquals(TextDecoration.State.NOT_SET, component.decoration(TextDecoration.UNDERLINED)); assertEquals(TextDecoration.State.NOT_SET, component.decoration(TextDecoration.ITALIC)); }