Solved Get players ip

Discussion in 'Plugin Development' started by albin900, Jan 10, 2014.

Thread Status:
Not open for further replies.
  1. Im making a plugin that gets the players ip adress and stores it to a database.
    Im currently using:
    Code:java
    1. String ip = player.getAddress().getHostName();


    but when someone joins the server the ip adress is: XXX-XXX-XXX-XXX.mybroadband.com
    i want the adress to be: XXX.XXX.XXX.XXX.
    How can i do that?
     
  2. Offline

    Forseth11

  3. It a bit complicate because some adresses have: cX.XXX-XXX-XXX-XXX.mybroadband.com and some have
    XXX-XXX-XXX-XXX.domain5.mybroadband.com
     
  4. Offline

    JRL1004

    albin900 and what does just getAddress() return? I think you are getting the mybroadband thing because of the getHostName() but, then again, I never really messed about with IPs.
     
  5. Offline

    Forseth11

    albin900 How is that complicated? Just split it then go through a loop and add the ones that are good to a string.
     
  6. But i tried with just:
    Code:java
    1.  
    2. String ip = player.getAddress();
    3.  

    but it will not work.
     
  7. Offline

    JRL1004

    albin900 can you do getAddress().toString()? I thing just getAddress() returns an INet address or something.
     
  8. Thanks That worked :)
    After that i was replacing the / and : in the string :)
     
  9. Offline

    JRL1004

    albin900 So everything is sorted then, I take it? If so make sure you mark this as solved so other threads can get some attention.
     
Thread Status:
Not open for further replies.

Share This Page