null on event.getPlayer().getAddress()?
molor opened this issue ยท 8 comments
PacketType.Login.Server.DISCONNECT.
Player player = packetEvent.getPlayer();
System.out.println(player);
System.out.println(player.getClass().getName());
System.out.println(player.getName());
System.out.println(player.getLocation());
System.out.println(player.getAddress());
Returns:
CraftPlayer{name=Test}
org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer
Test
Location{world=CraftWorld{name=test},x=51.5,y=69.0,z=-68.5,pitch=0.0,yaw=1.3607771}
null
Before build 375, it worked correctly. How to get the player's address now?!
@dmulloy2, but it worked in builds 374- and stopped in 375+. I did not change the server jar or any other plugins. This problem is only in ProtocolLib.
commit in question: 390c21f
my guess would be that by returning the updated player, we return the disconnected who obviously doesn't have an address anymore.
not sure what the proper way to address this would be. you can't expect a disconnected player to have an address, but I can understand why you would want to check for that.
event.getPlayer().getClass()
in builds 374-:
class com.comphenix.protocol.injector.server.InjectorContainer$$EnhancerByCGLIB$$19efa65b
375+:
class org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer
yes, what you see in 374 is a so called TemporaryPlayer, used when protocollib doesn't have a real player at hand. TemporaryPlayers are really limited, they only implement a few methods. thats why 375 introduced a mechanism that limits the use of TemporaryPlayers by checking if we have a better alternative at hand when you actually call getPlayer.
the issue you have now is that the player instance you get instead of the temp player represents a disconnected player without an address. I am really not sure how to deal with it properly. it is definetly the right thing to return an up to date player instance.
You could always cache the address when you have access to it and use the cached value on disconnect
If player connects to the server and instantly gets kicked because of "Connection throttled" (for example), then I never have access to it's address..