Search in sources :

Example 31 with ChatComponentText

use of net.minecraft.server.v1_14_R1.ChatComponentText in project WildChests by BG-Software-LLC.

the class NMSInventory_v1_12_R1 method openPage.

@Override
public void openPage(Player player, com.bgsoftware.wildchests.objects.inventory.CraftWildInventory inventory) {
    EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    String title = inventory.getTitle();
    Container container = createContainer(entityPlayer.inventory, entityPlayer, inventory);
    container.windowId = entityPlayer.nextContainerCounter();
    TileEntityWildChest tileEntityWildChest = getTileEntity(inventory.getOwner());
    entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, tileEntityWildChest.getContainerName(), new ChatComponentText(title), inventory.getSize()));
    entityPlayer.activeContainer = container;
    entityPlayer.activeContainer.addSlotListener(entityPlayer);
}
Also used : Container(net.minecraft.server.v1_12_R1.Container) TileEntityContainer(com.bgsoftware.wildchests.objects.containers.TileEntityContainer) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) PacketPlayOutOpenWindow(net.minecraft.server.v1_12_R1.PacketPlayOutOpenWindow) ChatComponentText(net.minecraft.server.v1_12_R1.ChatComponentText)

Example 32 with ChatComponentText

use of net.minecraft.server.v1_14_R1.ChatComponentText in project WildChests by BG-Software-LLC.

the class NMSInventory_v1_8_R3 method openPage.

@Override
public void openPage(Player player, com.bgsoftware.wildchests.objects.inventory.CraftWildInventory inventory) {
    EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    String title = inventory.getTitle();
    Container container = createContainer(entityPlayer.inventory, entityPlayer, inventory);
    container.windowId = entityPlayer.nextContainerCounter();
    TileEntityWildChest tileEntityWildChest = getTileEntity(inventory.getOwner());
    entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, tileEntityWildChest.getContainerName(), new ChatComponentText(title), inventory.getSize()));
    entityPlayer.activeContainer = container;
    entityPlayer.activeContainer.addSlotListener(entityPlayer);
}
Also used : TileEntityContainer(com.bgsoftware.wildchests.objects.containers.TileEntityContainer) Container(net.minecraft.server.v1_8_R3.Container) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) PacketPlayOutOpenWindow(net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow) ChatComponentText(net.minecraft.server.v1_8_R3.ChatComponentText)

Example 33 with ChatComponentText

use of net.minecraft.server.v1_14_R1.ChatComponentText in project TheAPI by TheDevTec.

the class v1_11_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_11_R1.ChatClickable) ArrayList(java.util.ArrayList) ChatModifier(net.minecraft.server.v1_11_R1.ChatModifier) IChatBaseComponent(net.minecraft.server.v1_11_R1.IChatBaseComponent) IChatBaseComponent(net.minecraft.server.v1_11_R1.IChatBaseComponent) Component(me.devtec.shared.components.Component) ChatComponentText(net.minecraft.server.v1_11_R1.ChatComponentText) ChatHoverable(net.minecraft.server.v1_11_R1.ChatHoverable)

Example 34 with ChatComponentText

use of net.minecraft.server.v1_14_R1.ChatComponentText in project TheAPI by TheDevTec.

the class v1_11_R1 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.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);
        c = c.getExtra();
    }
    return main.a().isEmpty() ? empty : main;
}
Also used : ChatClickable(net.minecraft.server.v1_11_R1.ChatClickable) ChatModifier(net.minecraft.server.v1_11_R1.ChatModifier) IChatBaseComponent(net.minecraft.server.v1_11_R1.IChatBaseComponent) ChatComponentText(net.minecraft.server.v1_11_R1.ChatComponentText) ChatHoverable(net.minecraft.server.v1_11_R1.ChatHoverable)

Example 35 with ChatComponentText

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

Aggregations

ArrayList (java.util.ArrayList)30 Component (me.devtec.shared.components.Component)30 ChatClickable (net.minecraft.server.v1_10_R1.ChatClickable)4 ChatComponentText (net.minecraft.server.v1_10_R1.ChatComponentText)4 ChatHoverable (net.minecraft.server.v1_10_R1.ChatHoverable)4 ChatComponentText (net.minecraft.server.v1_12_R1.ChatComponentText)4 IChatBaseComponent (net.minecraft.server.v1_12_R1.IChatBaseComponent)4 ChatClickable (net.minecraft.server.v1_13_R1.ChatClickable)4 ChatComponentText (net.minecraft.server.v1_13_R1.ChatComponentText)4 ChatHoverable (net.minecraft.server.v1_13_R1.ChatHoverable)4 ChatModifier (net.minecraft.server.v1_13_R1.ChatModifier)4 IChatBaseComponent (net.minecraft.server.v1_13_R1.IChatBaseComponent)4 ChatClickable (net.minecraft.server.v1_8_R1.ChatClickable)4 ChatComponentText (net.minecraft.server.v1_8_R1.ChatComponentText)4 ChatHoverable (net.minecraft.server.v1_8_R1.ChatHoverable)4 ChatModifier (net.minecraft.server.v1_8_R1.ChatModifier)4 IChatBaseComponent (net.minecraft.server.v1_8_R1.IChatBaseComponent)4 ChatComponentText (net.minecraft.server.v1_8_R3.ChatComponentText)4 ChatClickable (net.minecraft.server.v1_12_R1.ChatClickable)3 ChatHoverable (net.minecraft.server.v1_12_R1.ChatHoverable)3