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);
}
}
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);
}
}
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);
}
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();
}
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);
}
Aggregations