Java (Minecraft) IP address in Config store and query?

En
- in Plugins
5

I'm currently writing a Minecraft plugin that has a special ban / unban system.

Now I want to make it so that if the player "ABC" is banned for "hacking" and with the account "CBA" tries to join, this is automatically banned for "Banumgehung".

However, my question now is:

We can I save the IP address of the player "ABC" in a config?

I would like to save that in a list, which I can do, but somehow I can't get it to correctly query and save the IP address.

PS: Unfortunately it does not work with p.getIPAddress (); (not for me, if I did not make a mistake).

PPS: Unfortunately, I'm not allowed to publish the source code, because I have a contract with the network, which prohibits this. : /

an

With

p.getIpaddress ()

it should work. (Small p and small a).

PS: It sounds like you're saving the PLAY NAME and the IP in a list. That can end badly. Instead, you should save the UUID and the IP in the list.

(Apart from the fact that this plugin is a bad idea, because it bans whole families at once, since they share a router (= an IP) → you are forced (or it would be appropriate) to unbind anyone who says " My brother hacked, but not me "→ a lot of work.).

an

I found this on the internet. That works in any case.

public string p () {
String s = this.playerConnection.networkManager.getSocketAddress (). ToString ();

s = s.substring (s.indexOf ("/") + 1);
s = s.substring (0, s.indexOf (":"));
return s;
}

getSocketAddress () returns the socket address (= IP address + port). Then just cut the port away at the back, as in the function I posted and done.

En

Ok thanks for the help & for your opinion.

This is also the goal of the entire IP (in the example, the whole family) banish, as if z.b. Hans was banned, he can then no longer go to Justus' PC and bypass the ban.

In the example with "I have not hacked but my brother" internal processes are performed, with which this person can prove that or what it can be discussed.

But thanks anyway.

For example:

Unfortunately this is not possible. The Spigot API does not have "p.getIPAddress ()". There's "p.getAddress ()", which does not work either.

En

I've tried that and tried to rewrite some, but "playerConnection" is not found.

En

Thank you for the answers.

I have just got help from the development management and it helped me.

Everything works as it should.

I have created a method with the help of the Dev management:

public String getIP (Object player) {
return ((Player) player) .getAddress (). GetHostName ();
}

Then I simply access these and then save this in the config.