Sending Title Packet Doesn't Listen To Set Times

Discussion in 'Spigot Plugin Development' started by Joedon, May 17, 2016.

  1. Hi there! I have a method to send a player a title for a certain amount of time, but it's changing nothing. Here is my method, which I am calling with numbers like 400, but they are doing nothing but sending for the default time.

    Code (Text):
        public static void sendTab(Player p, String title, String subtitle, Integer fadein, Integer length, Integer fadeout){
            CraftPlayer craftplayer = (CraftPlayer) p;
            PlayerConnection connection = craftplayer.getHandle().playerConnection;
            PacketPlayOutTitle main = new PacketPlayOutTitle(EnumTitleAction.TITLE, ChatSerializer.a("{\"text\":\"" + title + "\"}"), 50, 50, 30);
            PacketPlayOutTitle sub = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, ChatSerializer.a("{\"text\":\"" + subtitle + "\"}"), 50, 50, 30);

    Thanks for any help!
  2. Why don't you put in the values then? You're currently just hard coding the values as "50","50", and "30".
  3. Tux


    You need to send a TIMES packet too
    • Agree Agree x 1
    • Informative Informative x 1
  4. Oh I'm stupid.

    Edit: Still does nothing but Tux told me why.
  5. So I'm retarded and don't know what to do after:

    Code (Text):
            PacketPlayOutTitle time = new PacketPlayOutTitle(EnumTitleAction.TIMES, ChatSerializer.a("{\"text\":\"" + subtitle + "\"}"));
    :/ I know there obviously more besides just sending that packet too.
  6. Hey! I'm usually the one asking for help but for this I can help :p

    You need to add ints in this order: FadeIn, Stay, FadeOut (Note this is in TICKS)
    And than you need to make the actual one with the same chatserializer.
    One with EnumTitleAction.TIMES and the 3 ints
    And one with EnumTitleAction.TITLE/SUBTITLE and without the 3 ints.
    And send both, timings first.

    If this is unoptimized or something, and someone recommends better alternative go with it. I'm not really experienced and I got this out of titleAPI. (After inspecting it's sourcecode on github)

    Next time you could look into that :)
  7. You could always send a blank title after a certain amount of time to remove the current title.