Search in sources :

Example 81 with IChatBaseComponent

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

the class CraftMetaBook method applyToItem.

void applyToItem(NBTTagCompound itemData, boolean handlePages) {
    super.applyToItem(itemData);
    if (hasTitle()) {
        itemData.setString(BOOK_TITLE.NBT, this.title);
    }
    if (hasAuthor()) {
        itemData.setString(BOOK_AUTHOR.NBT, this.author);
    }
    if (handlePages) {
        if (hasPages()) {
            NBTTagList list = new NBTTagList();
            for (IChatBaseComponent page : pages) {
                list.add(new NBTTagString(CraftChatMessage.fromComponent(page)));
            }
            itemData.set(BOOK_PAGES.NBT, list);
        }
        itemData.remove(RESOLVED.NBT);
    }
    if (generation != null) {
        itemData.setInt(GENERATION.NBT, generation);
    }
}
Also used : NBTTagList(net.minecraft.server.v1_12_R1.NBTTagList) NBTTagString(net.minecraft.server.v1_12_R1.NBTTagString) IChatBaseComponent(net.minecraft.server.v1_12_R1.IChatBaseComponent)

Example 82 with IChatBaseComponent

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

the class CraftMetaBookSigned method applyToItem.

@Override
void applyToItem(NBTTagCompound itemData) {
    super.applyToItem(itemData, false);
    if (hasTitle()) {
        itemData.setString(BOOK_TITLE.NBT, this.title);
    } else {
        itemData.setString(BOOK_TITLE.NBT, " ");
    }
    if (hasAuthor()) {
        itemData.setString(BOOK_AUTHOR.NBT, this.author);
    } else {
        itemData.setString(BOOK_AUTHOR.NBT, " ");
    }
    if (hasPages()) {
        NBTTagList list = new NBTTagList();
        for (IChatBaseComponent page : pages) {
            list.add(new NBTTagString(ChatSerializer.a(page)));
        }
        itemData.set(BOOK_PAGES.NBT, list);
    }
    itemData.setBoolean(RESOLVED.NBT, true);
    if (generation != null) {
        itemData.setInt(GENERATION.NBT, generation);
    } else {
        itemData.setInt(GENERATION.NBT, 0);
    }
}
Also used : NBTTagList(net.minecraft.server.v1_12_R1.NBTTagList) NBTTagString(net.minecraft.server.v1_12_R1.NBTTagString) IChatBaseComponent(net.minecraft.server.v1_12_R1.IChatBaseComponent)

Example 83 with IChatBaseComponent

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

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

use of net.minecraft.server.v1_14_R1.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)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