mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-21 23:51:29 +01:00
Remove extra bits after \u0000 in join addresses
Affects issues: - Fixed #2710
This commit is contained in:
parent
07dbfb9f20
commit
fd625b5002
@ -83,10 +83,13 @@ public class PlayerOnlineListener implements Listener {
|
||||
ServerUUID serverUUID = serverInfo.getServerUUID();
|
||||
boolean banned = PlayerLoginEvent.Result.KICK_BANNED == event.getResult();
|
||||
|
||||
String joinAddress = event.getHostname();
|
||||
if (!joinAddress.isEmpty()) {
|
||||
joinAddress = joinAddress.substring(0, joinAddress.lastIndexOf(':'));
|
||||
joinAddressCache.put(playerUUID, joinAddress);
|
||||
String address = event.getHostname();
|
||||
if (!address.isEmpty()) {
|
||||
address = address.substring(0, address.lastIndexOf(':'));
|
||||
if (address.contains("\u0000")) {
|
||||
address = address.substring(0, address.indexOf('\u0000'));
|
||||
}
|
||||
joinAddressCache.put(playerUUID, address);
|
||||
}
|
||||
dbSystem.getDatabase().executeTransaction(new BanStatusTransaction(playerUUID, serverUUID, banned));
|
||||
} catch (Exception e) {
|
||||
|
@ -118,7 +118,11 @@ public class PlayerOnlineListener implements FabricListener {
|
||||
private void onHandshake(HandshakeC2SPacket packet) {
|
||||
try {
|
||||
if (packet.getIntendedState() == NetworkState.LOGIN) {
|
||||
joinAddress.set(packet.getAddress());
|
||||
String address = packet.getAddress();
|
||||
if (address != null && address.contains("\u0000")) {
|
||||
address = address.substring(0, address.indexOf('\u0000'));
|
||||
}
|
||||
joinAddress.set(address);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
errorLogger.error(e, ErrorContext.builder().related(getClass(), "onHandshake").build());
|
||||
|
@ -61,7 +61,11 @@ public class SpongePlayerData implements PlatformPlayerData {
|
||||
|
||||
@Override
|
||||
public Optional<String> getJoinAddress() {
|
||||
return Optional.of(player.connection().virtualHost().getHostString());
|
||||
String address = player.connection().virtualHost().getHostString();
|
||||
if (address.contains("\u0000")) {
|
||||
address = address.substring(0, address.indexOf('\u0000'));
|
||||
}
|
||||
return Optional.of(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,6 +48,15 @@ public class VelocityPlayerData implements PlatformPlayerData {
|
||||
|
||||
@Override
|
||||
public Optional<String> getJoinAddress() {
|
||||
return player.getVirtualHost().map(InetSocketAddress::getHostString);
|
||||
return player.getVirtualHost()
|
||||
.map(InetSocketAddress::getHostString)
|
||||
.map(this::removeExtra);
|
||||
}
|
||||
|
||||
private String removeExtra(String address) {
|
||||
if (address.contains("\u0000")) {
|
||||
return address.substring(0, address.indexOf('\u0000'));
|
||||
}
|
||||
return address;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user