Getting an IP on PlayerJoinEvent

Discussion in 'Plugin Development' started by Booshayy, Feb 27, 2014.

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

    Booshayy

    Hey there.

    I'm helping a friend run a UHC server, and I need to be able to instantly ban an alternate account of someone on the universal ban list.

    So basically, what I need to do is get the IP of a player on them joining (Using PlayerJoinEvent), and see if it matches any of the IPs of the usernames on the universal ban list (all players on it are already banned).

    Any advice?

    Thanks in advance.
     
  2. Offline

    Borlea

    player.getAddress().toString() will return the ip
    it will also contain a port. and a / which can avoided by doing
    player.getAddress().toString().replace("/", "").split(":")[0]
    That will return the players ip address in string, then loop through all the banned ip address's and check if its the players.
     
  3. Offline

    Booshayy

    Well I don't have the banned players' IPs stored.
    How do I check the username for an IP?
     
  4. Offline

    Borlea

    Its impossible to get the ip of a offline player. If you use essentials you could read the players userdata file and getting the ip from that.
     
  5. Offline

    Jake6177

    In reference to this, you can collect user data like essentials yourself and reference their IP from that.
     
  6. Offline

    iiHeroo

    Code:java
    1. p.getAddress().getAddress().getHostAddress());
     
Thread Status:
Not open for further replies.

Share This Page