[Tut] How to make the fancy title thing in the Middle and Tab List Headers + Footers!

Discussion in 'Spigot Plugin Development' started by Wounded_Slug, Sep 4, 2014.

  1. Not sure where to post this, since I don't need help. It's a friendly tutorial!

    First you want to make sure they're running 1.8:
    Code (Text):
    if(((CraftPlayer) e.getPlayer()).getHandle().playerConnection.networkManager.getVersion() >= 47)
    Then Declare the IChatBaseComponent for the Title
    Code (Text):
    IChatBaseComponent chatTitle = ChatSerializer.a("{\"text\": \"You are using 1.8! Expect Bugs!\"}");
    Then make the packet!

    Code (Text):
    PacketTitle title = new PacketTitle(Action.TITLE, chatTitle);

    Then send it away. Woosh!
    Code (Text):
    ((CraftPlayer) e.getPlayer()).getHandle().playerConnection.sendPacket(title);
    Do the same thing but with Action.SUBTITLE after sending the title packet to make a subtitle!


    To set the length that the title shows up for, do
    Code (Text):
    PacketTitle length = newPacketTitle(Action.TIMES, *fadeInTime*, *stayOnScreenTime*, *fadeOutTime*);
    And then send it away in they same way.
    Code (Text):
    ((CraftPlayer) e.getPlayer()).getHandle().playerConnection.sendPacket(length);
    Note: the times are in ticks. Meaning if you set fadeInTime to 20, it'll be second. 40 it'll be 2 seconds, etc.
    Also Note: You should send the length packet before the title packet.
    Final Note: Action is org.spigotmc.ProtocolInjector.PacketTitle.Action;



    Bonus: How to do Headers + Footers

    Code (Text):
    IChatBaseComponent tabTitle = ChatSerializer.a("{\"text\": \"§bHeader\"}");
                        IChatBaseComponent tabFoot = ChatSerializer.a("{\"text\": \"Footer\"}");
                     
                        PacketTabHeader header = new PacketTabHeader(tabTitle, tabFoot);
                     
                        ((CraftPlayer) e.getPlayer()).getHandle().playerConnection.sendPacket(header);
     
    #1 Wounded_Slug, Sep 4, 2014
    Last edited: Sep 4, 2014
    • Like Like x 18
    • Useful Useful x 13
    • Funny Funny x 2
    • Creative Creative x 1
  2. Great resource! Do you think that the red world border tint would be possible with something like that?
     
  3. Spigot doesn't have support yet, but if you're clever enough (I'm not) You could put it in spigot yourself.
    Same with http://wiki.vg/Protocol#Chat_Message positions.
     
  4. You should add screenshot's so people Like myself that don't code can easily see what you're doing :p
     
    • Agree Agree x 4
    • Optimistic Optimistic x 1
  5. danjb2000

    danjb2000 Retired Moderator
    Retired Supporter

    Thread moved => Plugin development.
     
  6. Wow it works really well :D
     
  7. JamesJ

    Supporter

  8. How did you make that banner?
     
  9. JamesJ

    Supporter

    Someone made me it :p
     
    • Winner Winner x 1
  10. kvq

    kvq

    How to fix ??
    [​IMG]
     
  11. @kvq make sure your spigot is up to date.
     
    • Agree Agree x 2
    • Like Like x 1
  12. Dmck2b

    Services Staff

    Ensure you are depending on the latest patched spigot build.
     
  13. kvq

    kvq

    I'm user last verison . Can you say me what i need to do (first time use spigot API)
    [​IMG]
     
    #13 kvq, Sep 30, 2014
    Last edited: Jul 19, 2016
  14. danjb2000

    danjb2000 Retired Moderator
    Retired Supporter

    Not sure that's the latest version.. We can't assist you in downloading it unfortunately, but if you do some searching around you will find it
     
  15. kvq

    kvq

    Ok , find newer version not problem for me ))
     
  16. kvq

    kvq

    Thanks , i download last verison and all working perfect
     
  17. I'm kind of confused... Would all this code go inside of the PlayerJoinEvent EventHandler?

    If so, I just pasted the 'if' statement in there (Yes, I changed the e to the name of my Event) and it gave me all sorts of issues regarding CraftPlayer not being able to be resolved to a type.

    EDIT:

    So now I've figured it out up to the playerConnection part. It tells me "playerConnection cannot be resolved or is not a field".
     
    #17 Ebear, Oct 23, 2014
    Last edited: Oct 23, 2014
  18. @Ebear what version of Spigot are you using o_O
     
  19. I think the latest patch... Is there any way I can check for sure?
     
  20. @Ebear I saw your post on Bukkit. getName() should be getHandle(), your cast should be to CraftPlayer and p.getPlayer() should just be p. Also note that you need to depend on CraftBukkit/Spigot.