Solved [Question] How to check Client Game Version?

Discussion in 'Plugin Development' started by ebear, Oct 22, 2014.

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

    ebear

    So I'm wondering how I can check a player whilst they're joining to make sure they're running a specific client version.

    So I've seen people putting a specific if statement in the EventHandler for the player joining...

    But, I don't know what it is.

    So I've tried (Keeping in mind that p is the Event)
    Code:
    if(((Player) p.getPlayer()).getName().playerConnection.networkManager.getVersion() >= 47)
    But it says that "playerConnection cannot be resolved or is not a field"

    Can someone help me with this?
     
  2. Offline

    mythbusterma

    ebear

    Why would a String have a publicly visible field "playerConnection," at least try to think about what you're doing here...
     
  3. Offline

    TheCodingCat

    cast the player to craftPlayer instead of player ebear
     
  4. Offline

    ebear


    Thank you for your kind words.

    Edit: By the way, you're supposed to be constructive on these Forums... Or has that rule changed?


    Ok. Now it's casting to CraftPlayer. My IDE has decided to tell me everything is wrong now...

    This code
    Code:
    if(((CraftPlayer) p.getHandle().playerConnection.networkManager.getVersion() >= 47)
    Tells me that "The operator >= is undefined for the argument type(s) CraftPlayer, int"

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
    comniemeer likes this.
  5. Offline

    mythbusterma

    ebear

    This is an easy fix: learn Java.
     
  6. Offline

    TheCodingCat

    ((CraftPlayer)p).getHandle()
     
    ebear and VG.Developments like this.
  7. Offline

    ebear

    Probably should have mentioned I'm not the most experienced Java Coder. When it comes to Java, my knowledge is about a 4/10. Sorry for the confusion.
     
  8. Offline

    Ronbo

    The point here is you learn Java before trying to code plugins.
     
  9. Offline

    ebear


    That much is understood. I thought I'd known enough. Well, I guess there's always room for learning.
     
  10. Offline

    Ronbo

    Anyways you're missing a parenthesis.
     
    ebear likes this.
  11. Offline

    SmooshCakez

    If your knowledge of Java is about 4/10, you'd realize that your problem is that you're missing a parenthesis.

    Cast player to CraftPlayer, use .getHandle(), playerConnection, networkManager, getVersion(). Also, p is a misleading name for an event.
     
  12. Offline

    ebear

    Gotcha. Thanks. The code itself was from something for a 1.8 feature, so it was something I was trying. Thanks for the help.

    I guess the same as the above response would be sufficient for this.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
Thread Status:
Not open for further replies.

Share This Page