Check if a title or subtitle is displayed to player

Discussion in 'Spigot Plugin Development' started by Vert3x, May 8, 2017.

Thread Status:
Not open for further replies.
  1. Hello, I'd like to know if there's any way to check if a player is viewing a title or a subtitle. Even in nms.
  2. I don't think so as the only involvement the server has with titles/subtitles is sending them to begin with, and after the client receives the packet it then handles the rest. I wonder if perhaps you're looking for the wrong solution to the problem - would you mind explaining the situation a bit more? Is your plugin sending the titles to begin with, or another plugin?
    #2 KingDragonRider, May 8, 2017
    Last edited: May 8, 2017
    • Agree Agree x 2
  3. Uhm... ok. I use a sendSubTitle methods in a class I have and I wanted to make it so that if the player already is seeing a title it was being kept and the subtitle was sent at the same time, otherwise I would have sent an empty one through another method I did. I don't use Bukkit's method because of versions compatibility, indeed by using that I check for the version and eventually use the packet.
  4. Ah okay. In that case, if I were you I would store the time when the player was last sent a title packet somewhere (get the time with System.currentTimeMillis()). When you want to see if a player is still viewing that title, compare the current time with the last time the player was sent a title and check if it has been longer than the duration of the title.
  5. Packet listening is a bit exaggerated for an interversional plugin; if I really don't have any other way to do it, this is not worth it. I appreciate the help though!
  6. Well this is good advice either way, you don't need the packet listener if you're the one sending the titles!

    Just track the last time you sent each player a title in a map as suggested, then use that map to know if a player is still viewing one.
  7. Mind my plugin is for sure not the only title source, so this would change really minimally what would happen by sending directly a new empty title without listening at all for any other title out there.
  8. Sorry I didn't mean to suggest checking for packets as I got the impression from your reply to my first post that it was only your plugin sending the titles.
    • Useful Useful x 1
  9. Perhaps I wrong and was not expressive enough. Well, I'm assuming there is no actual way to do this, so thank you all anyways for your replies!
    • Like Like x 1
Thread Status:
Not open for further replies.