Solved Title

Discussion in 'Plugin Development' started by SmallDesk, Mar 23, 2018.

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

    SmallDesk

    Hey, I have been trying to send a player a title, and I think I have it all right, but nothing appears. It is called when player interacts (right clicks an item in my case) just for testing.

    Here is my code for the title:


    PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, ChatSerializer.a("{\"text\":\"#1\",\"color\":\"yellow\",\"bold\":true},{\"text\":\"You Won!\",\"bold\":true,\"color\":\"none\"}"), 20, 40, 20);
    ((CraftPlayer) p).getHandle().playerConnection.sendPacket(title);
     
  2. Why not just use player.sendTitle
     
  3. Offline

    ToldiIII

  4. Offline

    SmallDesk

  5. Offline

    wonsz

    player.sendTitle doesn't require TitleAPI:

    Code:
    p.sendTitle(title, subtitle, fadeInTime, stayTime, fadeOutTime);
     
  6. Offline

    SmallDesk

    I am using 1.8 Spigot API and that's not a method there
     
  7. @SmallDesk
    Yes there is, my 1.8.8 spigot jar has the method player.sendTitle(String title, String subtitle);
     
  8. Offline

    SmallDesk

    I have the spigot 1.8 Jar though
     
  9. Offline

    CostelabrMn

    Hey, SmallDesk, try using this code (i made some changes like sending a packet with the fade in, fade out, etc. stuff):

    Code:
        IChatBaseComponent chatTitle = ChatSerializer.a("{\"text\":\"" + ChatColor.GREEN + "Hello " + ChatColor.GOLD + " you" + "\"}");
    
        PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, chatTitle);
    PacketPlayOutTitle length = new PacketPlayOutTitle(5, 50, 5);
    
    ((CraftPlayer) p).getHandle().playerConnection.sendPacket(title);
                ((CraftPlayer) p).getHandle().playerConnection.sendPacket(length);
    
     
  10. Offline

    SmallDesk

    Thanks a lot! It actually worked. Solved, thank for the help man appreciate it.
     
  11. Offline

    CostelabrMn

    Glad you've solved your issue!
     
Thread Status:
Not open for further replies.

Share This Page