Solved Extract Position from Chat message (ProtocolLib)

Discussion in 'Spigot Plugin Development' started by Kiryu144, Feb 1, 2020.

  1. Looking at the following packet I am having a listener to:

    I am trying to get the Position Byte.
    I have tried a lot, but I don't really understand ProtocolAPI's Packet class.

    Here is what I have so far
    Code (Java):
                new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Server.CHAT) {
                    public void onPacketSending(PacketEvent event) {
                        String message = event.getPacket().getChatComponents().getValues().get(0).getJson();
  2. SteelPhoenix


    In newer versions ProtocolLib has an enum for this

    Code (Java):
    public ChatType getChatType() {
        return handle.getChatTypes().read(0);
    public void setChatType(ChatType type) {
        handle.getChatTypes().write(0, type);
    Otherwise you just read/write the byte at the first index
  3. Alright, that was the solution. Thank you! :D