Search in sources :

Example 76 with IChatBaseComponent

use of net.minecraft.server.v1_7_R4.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 77 with IChatBaseComponent

use of net.minecraft.server.v1_7_R4.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 78 with IChatBaseComponent

use of net.minecraft.server.v1_7_R4.IChatBaseComponent in project Ublisk by Derkades.

the class V1_12_R1 method sendActionBarMessage.

@Override
public void sendActionBarMessage(Player player, String message) {
    IChatBaseComponent dummyComponent = ChatSerializer.a("{\"text\":\"herobrine1337\"}");
    PacketPlayOutChat packet = new PacketPlayOutChat(dummyComponent, ChatMessageType.GAME_INFO);
    packet.components = new BaseComponent[] { new TextComponent(message) };
    CraftPlayer craftPlayer = (CraftPlayer) player;
    craftPlayer.getHandle().playerConnection.sendPacket(packet);
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) PacketPlayOutChat(net.minecraft.server.v1_12_R1.PacketPlayOutChat) IChatBaseComponent(net.minecraft.server.v1_12_R1.IChatBaseComponent) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)

Example 79 with IChatBaseComponent

use of net.minecraft.server.v1_7_R4.IChatBaseComponent in project FireAPI by FireBlade-Serv.

the class FireTitle method send.

public void send() {
    IChatBaseComponent basetitle = ChatSerializer.a("{\"text\": \"" + this.title + "\"}");
    IChatBaseComponent basesubtitle = ChatSerializer.a("{\"text\": \"" + this.subtitle + "\"}");
    PacketPlayOutTitle titlepacket = new PacketPlayOutTitle(EnumTitleAction.TITLE, basetitle);
    PacketPlayOutTitle subtitlepacket = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, basesubtitle);
    ((CraftPlayer) this.player).getHandle().playerConnection.sendPacket(titlepacket);
    ((CraftPlayer) this.player).getHandle().playerConnection.sendPacket(subtitlepacket);
    sendTime();
}
Also used : PacketPlayOutTitle(net.minecraft.server.v1_8_R3.PacketPlayOutTitle) IChatBaseComponent(net.minecraft.server.v1_8_R3.IChatBaseComponent) CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer)

Example 80 with IChatBaseComponent

use of net.minecraft.server.v1_7_R4.IChatBaseComponent in project McWiki by skylerdev.

the class CommandWiki method showBook.

/**
 * Shows book.
 *
 * @param pages
 *            The pages of the book to display in List<String>
 * @param playerName
 *            The name of the player
 */
private void showBook(List<String> pages, String playerName) {
    ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
    BookMeta meta = (BookMeta) book.getItemMeta();
    // Fancy stuff to serialize pages
    List<IChatBaseComponent> cPages = null;
    try {
        cPages = (List<IChatBaseComponent>) CraftMetaBook.class.getDeclaredField("pages").get(meta);
    } catch (IllegalAccessException | NoSuchFieldException e) {
        e.printStackTrace();
    }
    for (String page : pages) {
        IChatBaseComponent cPage = IChatBaseComponent.ChatSerializer.a(page);
        cPages.add(cPage);
    }
    meta.setTitle("McWiki");
    meta.setAuthor("Article");
    book.setItemMeta(meta);
    Bukkit.getPlayer(playerName).openBook(book);
}
Also used : CraftMetaBook(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftMetaBook) IChatBaseComponent(net.minecraft.server.v1_16_R3.IChatBaseComponent) ItemStack(org.bukkit.inventory.ItemStack) BookMeta(org.bukkit.inventory.meta.BookMeta)

Aggregations

ArrayList (java.util.ArrayList)74 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 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 List (java.util.List)14 IChatBaseComponent (net.minecraft.server.v1_12_R1.IChatBaseComponent)13 IChatBaseComponent (net.minecraft.server.v1_8_R3.IChatBaseComponent)13 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