mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-22 14:34:59 +01:00
Added the player his IP to the transferable data
This commit is contained in:
parent
9527709c59
commit
64b04330c3
3 changed files with 18 additions and 8 deletions
|
@ -6,30 +6,39 @@ import lombok.Getter;
|
|||
@AllArgsConstructor
|
||||
@Getter
|
||||
public class BedrockData {
|
||||
public static final int EXPECTED_LENGTH = 6;
|
||||
public static final int EXPECTED_LENGTH = 7;
|
||||
public static final String FLOODGATE_IDENTIFIER = "Geyser-Floodgate";
|
||||
|
||||
private String version;
|
||||
private String username;
|
||||
private String xuid;
|
||||
private int deviceId;
|
||||
private String languageCode;
|
||||
private int inputMode;
|
||||
private String ip;
|
||||
private int dataLength;
|
||||
|
||||
public BedrockData(String version, String username, String xuid, int deviceId, String languageCode, int inputMode) {
|
||||
this(version, username, xuid, deviceId, languageCode, inputMode, EXPECTED_LENGTH);
|
||||
public BedrockData(String version, String username, String xuid, int deviceId, String languageCode, int inputMode, String ip) {
|
||||
this(version, username, xuid, deviceId, languageCode, inputMode, ip, EXPECTED_LENGTH);
|
||||
}
|
||||
|
||||
public static BedrockData fromString(String data) {
|
||||
String[] split = data.split("\0");
|
||||
if (split.length != EXPECTED_LENGTH) return null;
|
||||
return new BedrockData(split[0], split[1], split[2], Integer.parseInt(split[3]), split[4], Integer.parseInt(split[5]), split.length);
|
||||
|
||||
return new BedrockData(
|
||||
split[0], split[1], split[2], Integer.parseInt(split[3]),
|
||||
split[4], Integer.parseInt(split[5]), split[6], split.length
|
||||
);
|
||||
}
|
||||
|
||||
public static BedrockData fromRawData(byte[] data) {
|
||||
return fromString(new String(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return version +'\0'+ username +'\0'+ xuid +'\0'+ deviceId +'\0'+ languageCode +'\0'+ inputMode;
|
||||
return version +'\0'+ username +'\0'+ xuid +'\0'+ deviceId +'\0'+ languageCode +'\0'+
|
||||
inputMode +'\0'+ ip;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,7 +221,8 @@ public class GeyserSession implements Player {
|
|||
authenticationData.getXboxUUID(),
|
||||
clientData.getDeviceOS().ordinal(),
|
||||
clientData.getLanguageCode(),
|
||||
clientData.getCurrentInputMode().ordinal()
|
||||
clientData.getCurrentInputMode().ordinal(),
|
||||
upstream.getSession().getAddress().getAddress().getHostAddress()
|
||||
));
|
||||
} catch (Exception e) {
|
||||
connector.getLogger().error("Failed to encrypt message", e);
|
||||
|
@ -230,7 +231,7 @@ public class GeyserSession implements Player {
|
|||
HandshakePacket handshakePacket = event.getPacket();
|
||||
event.setPacket(new HandshakePacket(
|
||||
handshakePacket.getProtocolVersion(),
|
||||
handshakePacket.getHostname() + '\0' + "Geyser-Floodgate" + '\0' + encrypted,
|
||||
handshakePacket.getHostname() + '\0' + BedrockData.FLOODGATE_IDENTIFIER + '\0' + encrypted,
|
||||
handshakePacket.getPort(),
|
||||
handshakePacket.getIntent()
|
||||
));
|
||||
|
|
|
@ -92,7 +92,7 @@ public class BlockStorage {
|
|||
}
|
||||
|
||||
private int legacyIdFor(int index) {
|
||||
int runtimeId = this.palette.get(index);
|
||||
int runtimeId = this.palette.getInt(index);
|
||||
return GlobalBlockPalette.getLegacyId(runtimeId);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue