Discussion in 'Spigot Plugin Development' started by ProJoosh, May 30, 2015.

  1. whats the code to send Action bar text (Text above hotbar) because PacketPlayOutChat isnt defined in 1.8

    Old Method:
    Code (Text):
         public void sendActionBar(Player p, String msg) {
             IChatBaseComponent cbc = ChatSerializer.a("{\"text\": \"" + msg + "\"}");
             PacketPlayOutChat ppoc = new PacketPlayOutChat(cbc, 2);
             ((CraftPlayer) p).getHandle().playerConnection.sendPacket(ppoc);
  2. it's more or less correct but the new packet is PacketPlayOutTitle.
    Code (Text):

            PacketPlayOutTitle pt = new PacketPlayOutTitle(EnumTitleAction.TITLE, title);
            PacketPlayOutTitle spt = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, subtitle);
  3. Emmm..... I'm pretty sure that PacketPlayOutChat is still defined in Spigot 1.8.
  4. Try use ProtocolLib.
    This is what i use w/ it:
    Code (Text):

        private static void sendChatPacket(Player player, String json) {
            PacketContainer chat = new PacketContainer(PacketType.Play.Server.CHAT);
            chat.getChatComponents().write(0, WrappedChatComponent.fromJson(json));
            chat.getBytes().write(0, (byte) 2);
            try {
                ProtocolLibrary.getProtocolManager().sendServerPacket(player, chat);
            } catch (InvocationTargetException e) {
                throw new IllegalStateException("Unable to send packet " + chat, e);