[ProtocolLib] Send JSON chat message packet?

Discussion in 'Plugin Development' started by spoony_loony, Dec 12, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    spoony_loony

    Hello guys!
    So, like many people out there the new 1.7.2 builds have been very exciting to me. I have been trying to solve the new chat message formatting. I've been using protocol lib 3.0.1, but am stuck with a nullpointerexception. Here's the source:

    Code:
    if (sender instanceof Player) {
    PacketContainer chatMessage = protocolManager.createPacket(PacketType.Play.Server.CHAT);
    chatMessage.getChatComponents().read(0).setJson("{text:\"CLICK\",clickEvent:{action:run_command,value:\"This is a test\"}");
    try {
    protocolManager.sendServerPacket((Player) sender, chatMessage);
    } catch (InvocationTargetException e) {
    e.printStackTrace();
    }
    }
    
    I am getting my errors on the "chatMessage.getChatComponents" part... I don't know what I am doing wrong.

    Any help would be appreciated. Thanks in advanced!
     
Thread Status:
Not open for further replies.

Share This Page