Use ComponentLike instead of Component or Chat in some places
This commit is contained in:
parent
49a32421c0
commit
d84e4c87dc
@ -288,7 +288,7 @@ public abstract sealed class Chat extends ChatStatic implements HoverEventSource
|
|||||||
* @param comp the component.
|
* @param comp the component.
|
||||||
* @return this.
|
* @return this.
|
||||||
*/
|
*/
|
||||||
public Chat thenPlayerName(Component comp) { return then(playerNameComponent(comp)); }
|
public Chat thenPlayerName(ComponentLike comp) { return then(playerNameComponent(comp)); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends a component consisting of a new line.
|
* Appends a component consisting of a new line.
|
||||||
|
@ -248,7 +248,7 @@ public abstract class ChatStatic {
|
|||||||
* @param c the {@link Component}.
|
* @param c the {@link Component}.
|
||||||
* @return a new {@link FormatableChat}.
|
* @return a new {@link FormatableChat}.
|
||||||
*/
|
*/
|
||||||
public static FormatableChat playerNameComponent(Component c) {
|
public static FormatableChat playerNameComponent(ComponentLike c) {
|
||||||
FormatableChat fc = chatComponent(c);
|
FormatableChat fc = chatComponent(c);
|
||||||
fc.builder.colorIfAbsent(NamedTextColor.WHITE);
|
fc.builder.colorIfAbsent(NamedTextColor.WHITE);
|
||||||
return fc;
|
return fc;
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
package fr.pandacube.lib.chat;
|
package fr.pandacube.lib.chat;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.ComponentLike;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A tree structure of {@link Chat} component intended to be rendered in chat using {@link #render(boolean)}.
|
* A tree structure of chat {@link Component} intended to be rendered in chat using {@link #render(boolean)}.
|
||||||
*/
|
*/
|
||||||
public class ChatTreeNode {
|
public class ChatTreeNode {
|
||||||
|
|
||||||
@ -19,7 +22,7 @@ public class ChatTreeNode {
|
|||||||
/**
|
/**
|
||||||
* The component for the current node.
|
* The component for the current node.
|
||||||
*/
|
*/
|
||||||
public final Chat component;
|
public final ComponentLike component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Children nodes.
|
* Children nodes.
|
||||||
@ -30,7 +33,7 @@ public class ChatTreeNode {
|
|||||||
* Construct a new {@link ChatTreeNode}.
|
* Construct a new {@link ChatTreeNode}.
|
||||||
* @param cmp the component for the current node.
|
* @param cmp the component for the current node.
|
||||||
*/
|
*/
|
||||||
public ChatTreeNode(Chat cmp) {
|
public ChatTreeNode(ComponentLike cmp) {
|
||||||
component = cmp;
|
component = cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +53,7 @@ public class ChatTreeNode {
|
|||||||
* Each element in the returned list represent 1 line of this tree view.
|
* Each element in the returned list represent 1 line of this tree view.
|
||||||
* Thus, the caller may send each line separately or at once, depending on the quantity of data.
|
* Thus, the caller may send each line separately or at once, depending on the quantity of data.
|
||||||
* @param console true to render for console, false otherwise.
|
* @param console true to render for console, false otherwise.
|
||||||
* @return an array of component, each element being a single line.
|
* @return a list of component, each element being a single line.
|
||||||
*/
|
*/
|
||||||
public List<Chat> render(boolean console) {
|
public List<Chat> render(boolean console) {
|
||||||
List<Chat> ret = new ArrayList<>();
|
List<Chat> ret = new ArrayList<>();
|
||||||
|
@ -432,12 +432,12 @@ public class ChatUtil {
|
|||||||
* alignment, much harder).
|
* alignment, much harder).
|
||||||
* @return a List containing each rendered line of the table.
|
* @return a List containing each rendered line of the table.
|
||||||
*/
|
*/
|
||||||
public static List<Component> renderTable(List<List<Chat>> data, String space, boolean console) {
|
public static List<Component> renderTable(List<List<ComponentLike>> data, String space, boolean console) {
|
||||||
List<List<Component>> compRows = new ArrayList<>(data.size());
|
List<List<Component>> compRows = new ArrayList<>(data.size());
|
||||||
for (List<Chat> row : data) {
|
for (List<ComponentLike> row : data) {
|
||||||
List<Component> compRow = new ArrayList<>(row.size());
|
List<Component> compRow = new ArrayList<>(row.size());
|
||||||
for (Chat c : row) {
|
for (ComponentLike c : row) {
|
||||||
compRow.add(c.getAdv());
|
compRow.add(c.asComponent());
|
||||||
}
|
}
|
||||||
compRows.add(compRow);
|
compRows.add(compRow);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user