Search in sources :

Example 21 with Component

use of me.devtec.shared.components.Component in project TheAPI by TheDevTec.

the class v1_16_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()) {
            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().toLowerCase()).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 chat.toArray(new IChatBaseComponent[0]);
}
Also used : ChatClickable(net.minecraft.server.v1_16_R1.ChatClickable) ArrayList(java.util.ArrayList) ChatModifier(net.minecraft.server.v1_16_R1.ChatModifier) IChatBaseComponent(net.minecraft.server.v1_16_R1.IChatBaseComponent) Component(me.devtec.shared.components.Component) IChatBaseComponent(net.minecraft.server.v1_16_R1.IChatBaseComponent) ChatComponentText(net.minecraft.server.v1_16_R1.ChatComponentText)

Example 22 with Component

use of me.devtec.shared.components.Component in project TheAPI by TheDevTec.

the class v1_16_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()) {
            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;
}
Also used : ChatClickable(net.minecraft.server.v1_16_R1.ChatClickable) ChatModifier(net.minecraft.server.v1_16_R1.ChatModifier) IChatBaseComponent(net.minecraft.server.v1_16_R1.IChatBaseComponent) Component(me.devtec.shared.components.Component) IChatBaseComponent(net.minecraft.server.v1_16_R1.IChatBaseComponent) ChatComponentText(net.minecraft.server.v1_16_R1.ChatComponentText)

Example 23 with Component

use of me.devtec.shared.components.Component in project TheAPI by TheDevTec.

the class v1_13_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()) {
            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;
}
Also used : ChatClickable(net.minecraft.server.v1_13_R2.ChatClickable) ChatModifier(net.minecraft.server.v1_13_R2.ChatModifier) IChatBaseComponent(net.minecraft.server.v1_13_R2.IChatBaseComponent) IChatBaseComponent(net.minecraft.server.v1_13_R2.IChatBaseComponent) Component(me.devtec.shared.components.Component) ChatComponentText(net.minecraft.server.v1_13_R2.ChatComponentText) ChatHoverable(net.minecraft.server.v1_13_R2.ChatHoverable)

Example 24 with Component

use of me.devtec.shared.components.Component in project TheAPI by TheDevTec.

the class v1_13_R2 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]);
}
Also used : ChatClickable(net.minecraft.server.v1_13_R2.ChatClickable) ArrayList(java.util.ArrayList) ChatModifier(net.minecraft.server.v1_13_R2.ChatModifier) IChatBaseComponent(net.minecraft.server.v1_13_R2.IChatBaseComponent) IChatBaseComponent(net.minecraft.server.v1_13_R2.IChatBaseComponent) Component(me.devtec.shared.components.Component) ChatComponentText(net.minecraft.server.v1_13_R2.ChatComponentText) ChatHoverable(net.minecraft.server.v1_13_R2.ChatHoverable)

Example 25 with Component

use of me.devtec.shared.components.Component in project TheAPI by TheDevTec.

the class v1_14_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]);
}
Also used : ChatClickable(net.minecraft.server.v1_14_R1.ChatClickable) ArrayList(java.util.ArrayList) ChatModifier(net.minecraft.server.v1_14_R1.ChatModifier) IChatBaseComponent(net.minecraft.server.v1_14_R1.IChatBaseComponent) Component(me.devtec.shared.components.Component) IChatBaseComponent(net.minecraft.server.v1_14_R1.IChatBaseComponent) ChatComponentText(net.minecraft.server.v1_14_R1.ChatComponentText) ChatHoverable(net.minecraft.server.v1_14_R1.ChatHoverable)

Aggregations

Component (me.devtec.shared.components.Component)38 ArrayList (java.util.ArrayList)19 ChatClickable (net.minecraft.network.chat.ChatClickable)6 ChatComponentText (net.minecraft.network.chat.ChatComponentText)6 ChatModifier (net.minecraft.network.chat.ChatModifier)6 IChatBaseComponent (net.minecraft.network.chat.IChatBaseComponent)6 ChatClickable (net.minecraft.server.v1_10_R1.ChatClickable)2 ChatComponentText (net.minecraft.server.v1_10_R1.ChatComponentText)2 ChatHoverable (net.minecraft.server.v1_10_R1.ChatHoverable)2 ChatModifier (net.minecraft.server.v1_10_R1.ChatModifier)2 IChatBaseComponent (net.minecraft.server.v1_10_R1.IChatBaseComponent)2 ChatClickable (net.minecraft.server.v1_11_R1.ChatClickable)2 ChatComponentText (net.minecraft.server.v1_11_R1.ChatComponentText)2 ChatHoverable (net.minecraft.server.v1_11_R1.ChatHoverable)2 ChatModifier (net.minecraft.server.v1_11_R1.ChatModifier)2 IChatBaseComponent (net.minecraft.server.v1_11_R1.IChatBaseComponent)2 ChatClickable (net.minecraft.server.v1_12_R1.ChatClickable)2 ChatComponentText (net.minecraft.server.v1_12_R1.ChatComponentText)2 ChatHoverable (net.minecraft.server.v1_12_R1.ChatHoverable)2 ChatModifier (net.minecraft.server.v1_12_R1.ChatModifier)2