@Override public @NonNull TranslatableComponent decoration(final @NonNull TextDecoration decoration, final TextDecoration.@NonNull State state) { switch(decoration) { case BOLD: return new TranslatableComponent(this.children, this.color, this.obfuscated, checkNotNull(state, "flag"), this.strikethrough, this.underlined, this.italic, this.clickEvent, this.hoverEvent, this.insertion, this.key, this.args); case ITALIC: return new TranslatableComponent(this.children, this.color, this.obfuscated, this.bold, this.strikethrough, this.underlined, checkNotNull(state, "flag"), this.clickEvent, this.hoverEvent, this.insertion, this.key, this.args); case UNDERLINE: return new TranslatableComponent(this.children, this.color, this.obfuscated, this.bold, this.strikethrough, checkNotNull(state, "flag"), this.italic, this.clickEvent, this.hoverEvent, this.insertion, this.key, this.args); case STRIKETHROUGH: return new TranslatableComponent(this.children, this.color, this.obfuscated, this.bold, checkNotNull(state, "flag"), this.underlined, this.italic, this.clickEvent, this.hoverEvent, this.insertion, this.key, this.args); case OBFUSCATED: return new TranslatableComponent(this.children, this.color, checkNotNull(state, "flag"), this.bold, this.strikethrough, this.underlined, this.italic, this.clickEvent, this.hoverEvent, this.insertion, this.key, this.args); default: throw new IllegalArgumentException(String.format("unknown decoration '%s'", decoration)); } }
@Override public @NonNull TranslatableComponent decoration(final @NonNull TextDecoration decoration, final TextDecoration.@NonNull State state) { switch(decoration) { case BOLD: return new TranslatableComponent(this.children, this.color, this.obfuscated, requireNonNull(state, "flag"), this.strikethrough, this.underlined, this.italic, this.clickEvent, this.hoverEvent, this.insertion, this.key, this.args); case ITALIC: return new TranslatableComponent(this.children, this.color, this.obfuscated, this.bold, this.strikethrough, this.underlined, requireNonNull(state, "flag"), this.clickEvent, this.hoverEvent, this.insertion, this.key, this.args); case UNDERLINED: return new TranslatableComponent(this.children, this.color, this.obfuscated, this.bold, this.strikethrough, requireNonNull(state, "flag"), this.italic, this.clickEvent, this.hoverEvent, this.insertion, this.key, this.args); case STRIKETHROUGH: return new TranslatableComponent(this.children, this.color, this.obfuscated, this.bold, requireNonNull(state, "flag"), this.underlined, this.italic, this.clickEvent, this.hoverEvent, this.insertion, this.key, this.args); case OBFUSCATED: return new TranslatableComponent(this.children, this.color, requireNonNull(state, "flag"), this.bold, this.strikethrough, this.underlined, this.italic, this.clickEvent, this.hoverEvent, this.insertion, this.key, this.args); default: throw new IllegalArgumentException(String.format("unknown decoration '%s'", decoration)); } }
@Override public @NonNull TranslatableComponent build() { checkState(this.key != null, "key must be set"); return new TranslatableComponent(this); } }
@Override public @NonNull TranslatableComponent build() { if(this.key == null) throw new IllegalStateException("key must be set"); return new TranslatableComponent(this); } }
@Override public @NonNull TranslatableComponent copy() { return new TranslatableComponent(this.children, this.color, this.obfuscated, this.bold, this.strikethrough, this.underlined, this.italic, this.clickEvent, this.hoverEvent, this.insertion, this.key, this.args); }
@Override public @NonNull TranslatableComponent copy() { return new TranslatableComponent(this.children, this.color, this.obfuscated, this.bold, this.strikethrough, this.underlined, this.italic, this.clickEvent, this.hoverEvent, this.insertion, this.key, this.args); }
@Override public @NonNull TranslatableComponent copy() { return new TranslatableComponent(this.children, this.color, this.obfuscated, this.bold, this.strikethrough, this.underlined, this.italic, this.clickEvent, this.hoverEvent, this.insertion, this.key, this.args); }
@Override public @NonNull TranslatableComponent append(final @NonNull Component component) { this.detectCycle(component); // detect cycle before modifying final List<Component> children = new ArrayList<>(this.children.size() + 1); children.addAll(this.children); children.add(component); return new TranslatableComponent(children, this.color, this.obfuscated, this.bold, this.strikethrough, this.underlined, this.italic, this.clickEvent, this.hoverEvent, this.insertion, this.key, this.args); }
@Override public @NonNull TranslatableComponent append(final @NonNull Component component) { this.detectCycle(component); // detect cycle before modifying final List<Component> children = new ArrayList<>(this.children.size() + 1); children.addAll(this.children); children.add(component); return new TranslatableComponent(children, this.color, this.obfuscated, this.bold, this.strikethrough, this.underlined, this.italic, this.clickEvent, this.hoverEvent, this.insertion, this.key, this.args); }
/** * Sets the translation key. * * @param key the translation key * @return a copy of this component */ public @NonNull TranslatableComponent key(final @NonNull String key) { return new TranslatableComponent(this.children, this.color, this.obfuscated, this.bold, this.strikethrough, this.underlined, this.italic, this.clickEvent, this.hoverEvent, this.insertion, checkNotNull(key, "key"), this.args); }
/** * Sets the translation key. * * @param key the translation key * @return a copy of this component */ public @NonNull TranslatableComponent key(final @NonNull String key) { return new TranslatableComponent(this.children, this.color, this.obfuscated, this.bold, this.strikethrough, this.underlined, this.italic, this.clickEvent, this.hoverEvent, this.insertion, requireNonNull(key, "key"), this.args); }
@Override public @NonNull TranslatableComponent clickEvent(final @Nullable ClickEvent event) { return new TranslatableComponent(this.children, this.color, this.obfuscated, this.bold, this.strikethrough, this.underlined, this.italic, event, this.hoverEvent, this.insertion, this.key, this.args); }
@Override public @NonNull TranslatableComponent insertion(final @Nullable String insertion) { return new TranslatableComponent(this.children, this.color, this.obfuscated, this.bold, this.strikethrough, this.underlined, this.italic, this.clickEvent, this.hoverEvent, insertion, this.key, this.args); }
/** * Sets the translation arguments for this component. * * @param args the translation arguments * @return this component */ public @NonNull TranslatableComponent args(final @NonNull List<Component> args) { return new TranslatableComponent(this.children, this.color, this.obfuscated, this.bold, this.strikethrough, this.underlined, this.italic, this.clickEvent, this.hoverEvent, this.insertion, this.key, args); }
@Override public @NonNull TranslatableComponent mergeColor(final @NonNull Component that) { return new TranslatableComponent(this.children, that.color(), this.obfuscated, this.bold, this.strikethrough, this.underlined, this.italic, this.clickEvent, this.hoverEvent, this.insertion, this.key, this.args); }
@Override public @NonNull TranslatableComponent hoverEvent(final @Nullable HoverEvent event) { if(event != null) this.detectCycle(event.value()); // detect cycle before modifying return new TranslatableComponent(this.children, this.color, this.obfuscated, this.bold, this.strikethrough, this.underlined, this.italic, this.clickEvent, event, this.insertion, this.key, this.args); }
@Override public @NonNull TranslatableComponent mergeEvents(final @NonNull Component that) { return new TranslatableComponent(this.children, this.color, this.obfuscated, this.bold, this.strikethrough, this.underlined, this.italic, that.clickEvent(), that.hoverEvent(), this.insertion, this.key, this.args); }
@Override public @NonNull TranslatableComponent hoverEvent(final @Nullable HoverEvent event) { if(event != null) this.detectCycle(event.value()); // detect cycle before modifying return new TranslatableComponent(this.children, this.color, this.obfuscated, this.bold, this.strikethrough, this.underlined, this.italic, this.clickEvent, event, this.insertion, this.key, this.args); }
@Override public @NonNull TranslatableComponent hoverEvent(final @Nullable HoverEvent event) { if(event != null) this.detectCycle(event.value()); // detect cycle before modifying return new TranslatableComponent(this.children, this.color, this.obfuscated, this.bold, this.strikethrough, this.underlined, this.italic, this.clickEvent, event, this.insertion, this.key, this.args); }
@Override public @NonNull TranslatableComponent mergeDecorations(final @NonNull Component that) { final TextDecoration.State obfuscated = that.decoration(TextDecoration.OBFUSCATED) != TextDecoration.State.NOT_SET ? that.decoration(TextDecoration.OBFUSCATED) : this.obfuscated; final TextDecoration.State bold = that.decoration(TextDecoration.BOLD) != TextDecoration.State.NOT_SET ? that.decoration(TextDecoration.BOLD) : this.bold; final TextDecoration.State strikethrough = that.decoration(TextDecoration.STRIKETHROUGH) != TextDecoration.State.NOT_SET ? that.decoration(TextDecoration.STRIKETHROUGH) : this.strikethrough; final TextDecoration.State underlined = that.decoration(TextDecoration.UNDERLINED) != TextDecoration.State.NOT_SET ? that.decoration(TextDecoration.UNDERLINED) : this.underlined; final TextDecoration.State italic = that.decoration(TextDecoration.ITALIC) != TextDecoration.State.NOT_SET ? that.decoration(TextDecoration.ITALIC) : this.italic; return new TranslatableComponent(this.children, this.color, obfuscated, bold, strikethrough, underlined, italic, this.clickEvent, this.hoverEvent, this.insertion, this.key, this.args); }