Search in sources :

Example 76 with IChatBaseComponent

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

the class v1_9_R1 method toIChatBaseComponents.

@Override
public Object toIChatBaseComponents(Component c) {
    List<IChatBaseComponent> chat = new ArrayList<>();
    chat.add(new ChatComponentText(""));
    while (c != null) {
        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);
        c = c.getExtra();
    }
    return chat.toArray(new IChatBaseComponent[0]);
}
Also used : ChatClickable(net.minecraft.server.v1_9_R1.ChatClickable) ArrayList(java.util.ArrayList) ChatModifier(net.minecraft.server.v1_9_R1.ChatModifier) IChatBaseComponent(net.minecraft.server.v1_9_R1.IChatBaseComponent) ChatComponentText(net.minecraft.server.v1_9_R1.ChatComponentText) ChatHoverable(net.minecraft.server.v1_9_R1.ChatHoverable)

Example 77 with IChatBaseComponent

use of net.minecraft.server.v1_14_R1.IChatBaseComponent in project L2X9RebootCore by 254nm.

the class AntiLink method outgoing.

@Override
public void outgoing(PacketEvent.Outgoing event) throws Throwable {
    if (event.getPacket() instanceof PacketPlayOutChat) {
        PacketPlayOutChat packet = (PacketPlayOutChat) event.getPacket();
        IChatBaseComponent message = (IChatBaseComponent) messageF.get(packet);
        if (message == null)
            return;
        List<String> list = manager.getConfig().getStringList("Blocked");
        for (String word : list) {
            if (message.toPlainText().contains(word)) {
                event.setCancelled(true);
                break;
            }
        }
    }
}
Also used : PacketPlayOutChat(net.minecraft.server.v1_12_R1.PacketPlayOutChat) IChatBaseComponent(net.minecraft.server.v1_12_R1.IChatBaseComponent)

Example 78 with IChatBaseComponent

use of net.minecraft.server.v1_14_R1.IChatBaseComponent in project L2X9RebootCore by 254nm.

the class TabRunnable method run.

@Override
public void run() {
    Bukkit.getOnlinePlayers().forEach(player -> {
        try {
            String headerStr = String.join("\n", manager.getConfig().getStringList("Header"));
            String footerStr = String.join("\n", manager.getConfig().getStringList("Footer"));
            IChatBaseComponent header = new ChatComponentText(manager.parsePlaceHolders(headerStr, player));
            IChatBaseComponent footer = new ChatComponentText(manager.parsePlaceHolders(footerStr, player));
            CraftPlayer craftPlayer = (CraftPlayer) player;
            PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter();
            headerField.set(packet, header);
            footerField.set(packet, footer);
            craftPlayer.getHandle().playerConnection.sendPacket(packet);
        } catch (Throwable t) {
            t.printStackTrace();
        }
    });
}
Also used : PacketPlayOutPlayerListHeaderFooter(net.minecraft.server.v1_12_R1.PacketPlayOutPlayerListHeaderFooter) IChatBaseComponent(net.minecraft.server.v1_12_R1.IChatBaseComponent) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) ChatComponentText(net.minecraft.server.v1_12_R1.ChatComponentText)

Example 79 with IChatBaseComponent

use of net.minecraft.server.v1_14_R1.IChatBaseComponent in project Cauldron by GhastGames.

the class TitleManager method set.

@Override
public void set(Player player, Title newTitle) {
    CraftPlayer craftPlayer = (CraftPlayer) player;
    IChatBaseComponent title = IChatBaseComponent.ChatSerializer.a("{text: \"" + newTitle.getTitle().replace("\"", "") + "\"}");
    PacketPlayOutTitle packetPlayOutTitle = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TITLE, title, newTitle.fadeIn, newTitle.stay, newTitle.fadeOut);
    IChatBaseComponent subtitle = IChatBaseComponent.ChatSerializer.a("{text: \"" + newTitle.getTitle().replace("\"", "") + "\"}");
    PacketPlayOutTitle packetPlayOutTitle2 = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.SUBTITLE, subtitle, newTitle.fadeIn, newTitle.stay, newTitle.fadeOut);
    craftPlayer.getHandle().playerConnection.sendPacket(packetPlayOutTitle);
    craftPlayer.getHandle().playerConnection.sendPacket(packetPlayOutTitle2);
}
Also used : PacketPlayOutTitle(net.minecraft.server.v1_8_R3.PacketPlayOutTitle) CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) IChatBaseComponent(net.minecraft.server.v1_8_R3.IChatBaseComponent)

Example 80 with IChatBaseComponent

use of net.minecraft.server.v1_14_R1.IChatBaseComponent in project PaperDev by Kamillaova.

the class CraftMetaBook method serialize.

@Override
Builder<String, Object> serialize(Builder<String, Object> builder) {
    super.serialize(builder);
    if (hasTitle()) {
        builder.put(BOOK_TITLE.BUKKIT, title);
    }
    if (hasAuthor()) {
        builder.put(BOOK_AUTHOR.BUKKIT, author);
    }
    if (hasPages()) {
        List<String> pagesString = new ArrayList<String>();
        for (IChatBaseComponent comp : pages) {
            pagesString.add(CraftChatMessage.fromComponent(comp));
        }
        builder.put(BOOK_PAGES.BUKKIT, pagesString);
    }
    if (generation != null) {
        builder.put(GENERATION.BUKKIT, generation);
    }
    return builder;
}
Also used : ArrayList(java.util.ArrayList) IChatBaseComponent(net.minecraft.server.v1_12_R1.IChatBaseComponent) NBTTagString(net.minecraft.server.v1_12_R1.NBTTagString)

Aggregations

ArrayList (java.util.ArrayList)76 BookMeta (org.bukkit.inventory.meta.BookMeta)41 Component (me.devtec.shared.components.Component)30 ItemStack (org.bukkit.inventory.ItemStack)28 GameProfile (com.mojang.authlib.GameProfile)23 IChatBaseComponent (net.minecraft.server.v1_12_R1.IChatBaseComponent)18 List (java.util.List)15 ServerListPingEvent (me.devtec.theapi.bukkit.events.ServerListPingEvent)15 PlayerProfile (me.devtec.theapi.bukkit.events.ServerListPingEvent.PlayerProfile)15 Player (org.bukkit.entity.Player)15 Channel (io.netty.channel.Channel)14 IChatBaseComponent (net.minecraft.server.v1_8_R3.IChatBaseComponent)14 IChatBaseComponent (net.minecraft.server.v1_10_R1.IChatBaseComponent)10 IChatBaseComponent (net.minecraft.server.v1_11_R1.IChatBaseComponent)10 IChatBaseComponent (net.minecraft.server.v1_14_R1.IChatBaseComponent)10 IChatBaseComponent (net.minecraft.server.v1_13_R2.IChatBaseComponent)9 IChatBaseComponent (net.minecraft.server.v1_15_R1.IChatBaseComponent)9 IChatBaseComponent (net.minecraft.server.v1_16_R3.IChatBaseComponent)9 IChatBaseComponent (net.minecraft.server.v1_16_R1.IChatBaseComponent)8 IChatBaseComponent (net.minecraft.server.v1_13_R1.IChatBaseComponent)7