Question

I'm making a plugin for my staff that can help them with some basic information. I'm trying to add a /ip for the server that will show the server ip, instead of the dns that they connect to.

I'm trying something like this

var InfoIP = Bukkit.getIp();
player.sendMessage("Server Ip: " + InfoIP);

Apparently it does work with Bukkit.getPort(); but it doesnt work with the ip. Is there another way to fix this?

I'm not looking for anything like this

var myip = "0.0.0.0";
player.sendMessage("Server Ip:" + myip);

I want the myip to be filled by the getIp instead of manually filling it.

Hopefully someone has a solution for this :) tnx.

Was it helpful?

Solution

In order to use the getIP method you must define it in your server properties.

there should be a line called server ip. once you have defined your ip in the properties it will return the ip. when you use the getIP method.

OTHER TIPS

Or you could use:

player.sendMessage(getServer().getAddress() + ":" + getServer().getPort());

hope this helped

~~ AceStudios

Or this:

if (!getServer().getPort() == "25565") {
player.sendMessage(getServer().getAddress() + ":" + getServer().getPort());
}
else {
player.sendMessage(getServer.getAddress());

Instead of using Bukkit.getIP(); try using Bukkit.getServer().getAddress();

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top