use of net.minecraft.network.chat.ChatClickable in project TheAPI by TheDevTec.
the class v1_18_R2 method toIChatBaseComponent.
@Override
public Object toIChatBaseComponent(Component c) {
ChatComponentText main = new ChatComponentText("");
while (c != null) {
if (c.getText() == null || c.getText().isEmpty()) {
c = c.getExtra();
continue;
}
ChatComponentText current = new ChatComponentText(c.getText());
main.a(current);
ChatModifier modif = current.c();
if (c.getColor() != null && !c.getColor().isEmpty()) {
if (c.getColor().startsWith("#"))
modif = modif.a(ChatHexColor.a(c.getColor()));
else
modif = modif.a(EnumChatFormat.a(c.getColor().charAt(0)));
}
if (c.getClickEvent() != null)
modif = modif.a(new ChatClickable(EnumClickAction.a(c.getClickEvent().getAction().name().toLowerCase()), c.getClickEvent().getValue()));
if (c.getHoverEvent() != null)
modif = modif.a(EnumHoverAction.a(c.getHoverEvent().getAction().name().toLowerCase()).a((IChatBaseComponent) toIChatBaseComponent(c.getHoverEvent().getValue())));
modif = modif.a(c.isBold());
modif = modif.b(c.isItalic());
modif = modif.e(c.isObfuscated());
modif = modif.c(c.isUnderlined());
modif = modif.d(c.isStrikethrough());
current.a(modif);
c = c.getExtra();
}
return main.b().isEmpty() ? ChatComponentText.d : main;
}
use of net.minecraft.network.chat.ChatClickable in project TheAPI by TheDevTec.
the class v1_18_R2 method toIChatBaseComponent.
@Override
public Object toIChatBaseComponent(List<Component> cc) {
ChatComponentText main = new ChatComponentText("");
for (Component c : cc) {
if (c.getText() == null || c.getText().isEmpty()) {
c = c.getExtra();
continue;
}
ChatComponentText current = new ChatComponentText(c.getText());
main.a(current);
ChatModifier modif = current.c();
if (c.getColor() != null && !c.getColor().isEmpty()) {
if (c.getColor().startsWith("#"))
modif = modif.a(ChatHexColor.a(c.getColor()));
else
modif = modif.a(EnumChatFormat.a(c.getColor().charAt(0)));
}
if (c.getClickEvent() != null) {
modif = modif.a(new ChatClickable(EnumClickAction.a(c.getClickEvent().getAction().name().toLowerCase()), c.getClickEvent().getValue()));
}
if (c.getHoverEvent() != null)
modif = modif.a(EnumHoverAction.a(c.getHoverEvent().getAction().name().toLowerCase()).a((IChatBaseComponent) toIChatBaseComponent(c.getHoverEvent().getValue())));
modif = modif.a(c.isBold());
modif = modif.b(c.isItalic());
modif = modif.e(c.isObfuscated());
modif = modif.c(c.isUnderlined());
modif = modif.d(c.isStrikethrough());
current.a(modif);
}
return main.b().isEmpty() ? ChatComponentText.d : main;
}
Aggregations