2

I'm trying to get the IP of my server. I couldn't use Bukkit.getServer().getIp() because I would need to set server-ip= in the server.properties file.

spongebob
  • 8,370
  • 15
  • 50
  • 83
Community
  • 143
  • 2
  • 10
  • 4
    I don't know Bukkit at all, but if it runs with JRE in a JVM try this: http://stackoverflow.com/questions/9481865/getting-the-ip-address-of-the-current-machine-using-java – PeterMmm Aug 12 '15 at 14:32

1 Answers1

1

In Java:

InetAddress IP = InetAddress.getLocalHost();
System.out.println("IP: " + IP.getHostAddress());

Another way if you're using Servlet:

request.getRemoteAddr();
spongebob
  • 8,370
  • 15
  • 50
  • 83
Anand Dwivedi
  • 1,452
  • 13
  • 23
  • 1
    Sorry, but that's mistaken: The method to get the server's IP is `ServletRequest.getLocalAddr()`: https://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#getLocalAddr%28%29 – Little Santi Aug 13 '15 at 12:04