PlayerLoginEvent.getHostname() not working?

Discussion in 'Plugin Development' started by TomShar, Jan 22, 2014.

Thread Status:
Not open for further replies.
  1. RawCode Has been already solved, or not? :eek: IP: player.getAddress().getAddress() hostname used for login:

    Code:java
    1. @EventHandler
    2. public void onPlayerLogin(PlayerLoginEvent event){
    3.  
    4. String hostname = event.getHostname();
    5.  
    6. }
     
  2. Offline

    acecheesecr14

    We have established that RawCode :D but it throws nothing if the server cant find the hostname the user used, and me and Assist were just discussing that same matter you pointed out...
     
  3. Offline

    L33m4n123

    So after reading through all your comments.. Where is your problem? Noone even tested it?

    Code:
        @EventHandler
        public void onLogin (PlayerLoginEvent e) {
            System.out.println("The player connects via: " + e.getHostname());
        }
    Works perfectly fine. End of story. It either returns the
    Code:
    NUMERIC-IP:Port
    that you used or
    Code:
    DOMAIN:Port 
    that you used

    Example:

    • localhost
    • 127.0.0.1
    For localhost it simply prints out
    Code:
    localhost:25565
    and for "127.0.0.1" it prints out
    Code:
    127.0.0.1:25565
    Only reason it does not work is if you either do not register the event correctly or are not using Bukkit. Or if you run it in offline mode maybe Tested with the newest Bukkit Dev Build
     
  4. L33m4n123Seems like you did not read through all of the comments as this has been already suggested.
     
  5. Offline

    acecheesecr14

    Well done to L33m4n123 for pointing it out a fourth time (I think)

    But like I have said previously, it won't return the hostname if it cant find it...

    And that answers the thread creators quesion

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

    RawCode

    it does not search it, client report domain used inside handshake procedure.

    and yes latest version have this field working.
     
    acecheesecr14 and Lionhard like this.
  7. Offline

    TomShar

    Why wouldn't it be able to find the hostname/can that be solved?
     
  8. TomShar You got already the solution... event.getHostname(); gets the domain/ip the user used to connect. The user has to use something, so it wont be blank/null.
    You used event.getPlayer().getHostname();
     
  9. Offline

    RawCode

    modded clients may set this field to special value, in this case you can't do anything.
     
Thread Status:
Not open for further replies.

Share This Page