[1.12.1 || 1.X] How to get client version ?

Discussion in 'Spigot Plugin Development' started by Uxon, Aug 23, 2017.

  1. Hello !

    I use Paperspigot 1.12.1 and ProtocolSupport on my server, and I would like to know the version of the players (and if possible any version of the server and what protocolHack they use, in order to lend this plugin to my friends who Use spigot 1.8 and viaversion).
    I tried this tutorial:
    Unfortunately I always get version "1.12.1", and when I put the server in spigot 1.8.9 I still get the server version but with some strange characters :
    [09:05:59] [Netty Epoll Server IO #2/INFO]: ProtocolVersionNumber : 47[m
    And the code (from the tutorial) : https://pastebin.com/dbWqZcnq

    Thank you !
  2. Can't you cast to CraftPlayer and get the client version from that?
  3. No I read that it works only whith 1.7 & 1.7 spigot which include protocolhack.
  4. You can use ClientStats
    or just modify/get the relevant code
    • Agree Agree x 2
  5. So I see,
    you could attempt to ask the ViaVersion developer if you use their version-get code.

    Or yeah, ClientStats.
    • Useful Useful x 1
  6. Thank you, I'll look at this right away!
  7. Thank you too <3
    • Friendly Friendly x 1
  8. I looked at the code on the github of ClienStats, I understood that it was using the API of ProtocolSupport, viaversion and when it does not find anyone it uses the packets. I did not find the part with the packets and I do not understand why it does not use it every time.
  9. They can't use the packets every times because the packets are rewrited by ViaVersion and ProtocolSupport. To make a client 1.8 use a 1.12 server, ProtocolSupport rewrites packets to ensure the 1.8 client has the 1.8 packets and not the 1.12, but to allow the 1.8 client to connect, they need to rewrite the login packet to fake the client version. Try using ViaVersion or ProtocolSupport's API instead of packets.