use of me.devtec.shared.components.Component in project TheAPI by TheDevTec.
the class v1_12_R1 method toIChatBaseComponents.
@Override
public Object toIChatBaseComponents(List<Component> components) {
List<IChatBaseComponent> chat = new ArrayList<>();
chat.add(new ChatComponentText(""));
for (Component c : components) {
if (c.getText() == null || c.getText().isEmpty()) {
c = c.getExtra();
continue;
}
ChatComponentText current = new ChatComponentText(c.getText());
chat.add(current);
ChatModifier modif = current.getChatModifier();
if (c.getColor() != null && !c.getColor().isEmpty()) {
modif = modif.setColor(EnumChatFormat.a(c.getColor().charAt(0)));
}
if (c.getClickEvent() != null)
modif = modif.setChatClickable(new ChatClickable(EnumClickAction.valueOf(c.getClickEvent().getAction().name()), c.getClickEvent().getValue()));
if (c.getHoverEvent() != null)
modif = modif.setChatHoverable(new ChatHoverable(EnumHoverAction.valueOf(c.getHoverEvent().getAction().name()), (IChatBaseComponent) toIChatBaseComponent(c.getHoverEvent().getValue())));
modif = modif.setBold(c.isBold());
modif = modif.setItalic(c.isItalic());
modif = modif.setRandom(c.isObfuscated());
modif = modif.setUnderline(c.isUnderlined());
modif = modif.setStrikethrough(c.isStrikethrough());
current.setChatModifier(modif);
}
return chat.toArray(new IChatBaseComponent[0]);
}
use of me.devtec.shared.components.Component in project TheAPI by TheDevTec.
the class v1_10_R1 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.addSibling(current);
ChatModifier modif = current.getChatModifier();
if (c.getColor() != null && !c.getColor().isEmpty()) {
modif = modif.setColor(EnumChatFormat.a(c.getColor().charAt(0)));
}
if (c.getClickEvent() != null)
modif = modif.setChatClickable(new ChatClickable(EnumClickAction.valueOf(c.getClickEvent().getAction().name()), c.getClickEvent().getValue()));
if (c.getHoverEvent() != null)
modif = modif.setChatHoverable(new ChatHoverable(EnumHoverAction.valueOf(c.getHoverEvent().getAction().name()), (IChatBaseComponent) toIChatBaseComponent(c.getHoverEvent().getValue())));
modif = modif.setBold(c.isBold());
modif = modif.setItalic(c.isItalic());
modif = modif.setRandom(c.isObfuscated());
modif = modif.setUnderline(c.isUnderlined());
modif = modif.setStrikethrough(c.isStrikethrough());
current.setChatModifier(modif);
}
return main.a().isEmpty() ? empty : main;
}
use of me.devtec.shared.components.Component in project TheAPI by TheDevTec.
the class v1_10_R1 method toIChatBaseComponents.
@Override
public Object toIChatBaseComponents(List<Component> components) {
List<IChatBaseComponent> chat = new ArrayList<>();
chat.add(new ChatComponentText(""));
for (Component c : components) {
if (c.getText() == null || c.getText().isEmpty()) {
c = c.getExtra();
continue;
}
ChatComponentText current = new ChatComponentText(c.getText());
chat.add(current);
ChatModifier modif = current.getChatModifier();
if (c.getColor() != null && !c.getColor().isEmpty()) {
modif = modif.setColor(EnumChatFormat.a(c.getColor().charAt(0)));
}
if (c.getClickEvent() != null)
modif = modif.setChatClickable(new ChatClickable(EnumClickAction.valueOf(c.getClickEvent().getAction().name()), c.getClickEvent().getValue()));
if (c.getHoverEvent() != null)
modif = modif.setChatHoverable(new ChatHoverable(EnumHoverAction.valueOf(c.getHoverEvent().getAction().name()), (IChatBaseComponent) toIChatBaseComponent(c.getHoverEvent().getValue())));
modif = modif.setBold(c.isBold());
modif = modif.setItalic(c.isItalic());
modif = modif.setRandom(c.isObfuscated());
modif = modif.setUnderline(c.isUnderlined());
modif = modif.setStrikethrough(c.isStrikethrough());
current.setChatModifier(modif);
}
return chat.toArray(new IChatBaseComponent[0]);
}
use of me.devtec.shared.components.Component in project TheAPI by TheDevTec.
the class v1_16_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.addSibling(current);
ChatModifier modif = current.getChatModifier();
if (c.getColor() != null && !c.getColor().isEmpty()) {
if (c.getColor().startsWith("#"))
modif = modif.setColor(ChatHexColor.a(c.getColor()));
else
modif = modif.setColor(EnumChatFormat.a(c.getColor().charAt(0)));
}
if (c.getClickEvent() != null)
modif = modif.setChatClickable(new ChatClickable(EnumClickAction.valueOf(c.getClickEvent().getAction().name()), c.getClickEvent().getValue()));
if (c.getHoverEvent() != null)
modif = modif.setChatHoverable(EnumHoverAction.a(c.getHoverEvent().getAction().name()).a((IChatBaseComponent) toIChatBaseComponent(c.getHoverEvent().getValue())));
modif = modif.setBold(c.isBold());
modif = modif.setItalic(c.isItalic());
modif = modif.setRandom(c.isObfuscated());
modif = modif.setUnderline(c.isUnderlined());
modif = modif.setStrikethrough(c.isStrikethrough());
current.setChatModifier(modif);
}
return main.getSiblings().isEmpty() ? ChatComponentText.d : main;
}
use of me.devtec.shared.components.Component in project TheAPI by TheDevTec.
the class v1_16_R3_Mohist method toIChatBaseComponents.
@Override
public Object toIChatBaseComponents(List<Component> components) {
List<ITextComponent> chat = new ArrayList<>();
chat.add(new StringTextComponent(""));
for (Component c : components) {
if (c.getText() == null || c.getText().isEmpty()) {
c = c.getExtra();
continue;
}
StringTextComponent current = new StringTextComponent(c.getText());
chat.add(current);
Style modif = current.func_150256_b();
if (c.getColor() != null && !c.getColor().isEmpty()) {
if (c.getColor().startsWith("#"))
modif = modif.func_240718_a_(Color.func_240745_a_(c.getColor()));
else {
for (TextFormatting e : TextFormatting.values()) if (e.toString().charAt(1) == c.getColor().charAt(0)) {
modif = modif.func_240718_a_(Color.func_240744_a_(e));
break;
}
}
}
if (c.getClickEvent() != null)
modif = modif.func_240715_a_(new ClickEvent(ClickEvent.Action.valueOf(c.getClickEvent().getAction().name()), c.getClickEvent().getValue()));
if (c.getHoverEvent() != null)
modif = modif.func_240716_a_(HoverEvent.Action.func_150684_a(c.getHoverEvent().getAction().name().toLowerCase()).func_240670_a_((ITextComponent) toIChatBaseComponent(c.getHoverEvent().getValue())));
if (c.isBold())
modif = modif.func_240720_a_(TextFormatting.BOLD);
if (c.isItalic())
modif = modif.func_240720_a_(TextFormatting.ITALIC);
if (c.isObfuscated())
modif = modif.func_240720_a_(TextFormatting.OBFUSCATED);
if (c.isUnderlined())
modif = modif.func_240720_a_(TextFormatting.UNDERLINE);
if (c.isStrikethrough())
modif = modif.func_240720_a_(TextFormatting.STRIKETHROUGH);
current.func_230530_a_(modif);
}
return chat.toArray(new ITextComponent[0]);
}
Aggregations