1.8.8 Change packets from 1.7 to 1.8 ProtocolInjector

Discussion in 'Spigot Plugin Development' started by Sebka97, Jan 31, 2020.

  1. Hello could someone help me this is code from 1.7 and I would like to update it to 1.8 but don't know how to update to the new packets in 1.8

    Code (Text):
    public static void sendTitle(final Player p, final String title, final String subTitle, final int fadeIn, final int stay, final int fadeOut) {
            final EntityPlayer player = ((CraftPlayer)p).getHandle();
            if (player.playerConnection.networkManager.getVersion() >= 47) {
                if (title != null) {
                    final IChatBaseComponent chatElement = ChatSerializer.a(title);
                    final ProtocolInjector.PacketTitle packet = new ProtocolInjector.PacketTitle(ProtocolInjector.PacketTitle.Action.TITLE, chatElement);
                    player.playerConnection.sendPacket((Packet)packet);
                }
                if (subTitle != null) {
                    final IChatBaseComponent chatElement = ChatSerializer.a(subTitle);
                    final ProtocolInjector.PacketTitle packet = new ProtocolInjector.PacketTitle(ProtocolInjector.PacketTitle.Action.SUBTITLE, chatElement);
                    player.playerConnection.sendPacket((Packet)packet);
                }
                final ProtocolInjector.PacketTitle length = new ProtocolInjector.PacketTitle(ProtocolInjector.PacketTitle.Action.TIMES, fadeIn, stay, fadeOut);
                player.playerConnection.sendPacket((Packet)length);
            }
        }
    }
     
    • Funny Funny x 1