3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-09 01:30:11 +01:00

Merge branch 'floodgate-2.0' of https://github.com/Tim203/Geyser into floodgate-2.0

Dieser Commit ist enthalten in:
DoctorMacc 2020-12-20 11:52:34 -05:00
Commit b0aceefd86
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6D6E7E059F186DB4
3 geänderte Dateien mit 18 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -76,7 +76,7 @@ public final class BedrockData {
return new BedrockData( return new BedrockData(
split[0], split[1], split[2], Integer.parseInt(split[3]), split[4], split[0], split[1], split[2], Integer.parseInt(split[3]), split[4],
Integer.parseInt(split[5]), Integer.parseInt(split[6]), split[7], Integer.parseInt(split[5]), Integer.parseInt(split[6]), split[7],
linkedPlayer, Boolean.parseBoolean(split[9]), split.length linkedPlayer, "1".equals(split[8]), split.length
); );
} }
@ -93,6 +93,7 @@ public final class BedrockData {
// The format is the same as the order of the fields in this class // The format is the same as the order of the fields in this class
return version + '\0' + username + '\0' + xuid + '\0' + deviceOs + '\0' + return version + '\0' + username + '\0' + xuid + '\0' + deviceOs + '\0' +
languageCode + '\0' + uiProfile + '\0' + inputMode + '\0' + ip + '\0' + languageCode + '\0' + uiProfile + '\0' + inputMode + '\0' + ip + '\0' +
fromProxy + '\0' + (linkedPlayer != null ? linkedPlayer.toString() : "null"); (fromProxy ? 1 : 0) + '\0' +
(linkedPlayer != null ? linkedPlayer.toString() : "null");
} }
} }

Datei anzeigen

@ -26,7 +26,6 @@
package org.geysermc.floodgate.util; package org.geysermc.floodgate.util;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.ToString;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.Base64; import java.util.Base64;
@ -34,7 +33,6 @@ import java.util.Base64;
import static java.lang.String.format; import static java.lang.String.format;
@AllArgsConstructor @AllArgsConstructor
@ToString
public final class RawSkin { public final class RawSkin {
public int width; public int width;
public int height; public int height;
@ -44,11 +42,20 @@ public final class RawSkin {
private RawSkin() { private RawSkin() {
} }
public static RawSkin decode(byte[] data) throws InvalidFormatException { public static RawSkin decode(byte[] data, int offset) throws InvalidFormatException {
return decode(data, 0); if (data == null || offset < 0 || data.length <= offset) {
return null;
}
if (offset == 0) {
return decode(data);
} }
public static RawSkin decode(byte[] data, int offset) throws InvalidFormatException { byte[] rawSkin = new byte[data.length - offset];
System.arraycopy(data, offset, rawSkin, 0, rawSkin.length);
return decode(rawSkin);
}
public static RawSkin decode(byte[] data) throws InvalidFormatException {
// offset is an amount of bytes before the Base64 starts // offset is an amount of bytes before the Base64 starts
if (data == null) { if (data == null) {
return null; return null;
@ -56,7 +63,7 @@ public final class RawSkin {
int maxEncodedLength = Base64Utils.getEncodedLength(64 * 64 * 4 + 9); int maxEncodedLength = Base64Utils.getEncodedLength(64 * 64 * 4 + 9);
// if the RawSkin is longer then the max Java Edition skin length // if the RawSkin is longer then the max Java Edition skin length
if ((data.length - offset) > maxEncodedLength) { if (data.length > maxEncodedLength) {
throw new InvalidFormatException(format( throw new InvalidFormatException(format(
"Encoded data cannot be longer then %s bytes! Got %s", "Encoded data cannot be longer then %s bytes! Got %s",
maxEncodedLength, data.length maxEncodedLength, data.length
@ -64,7 +71,7 @@ public final class RawSkin {
} }
// if the encoded data doesn't even contain the width, height (8 bytes, 2 ints) and isAlex // if the encoded data doesn't even contain the width, height (8 bytes, 2 ints) and isAlex
if ((data.length - offset) < Base64Utils.getEncodedLength(9)) { if (data.length < Base64Utils.getEncodedLength(9)) {
throw new InvalidFormatException("Encoded data must be at least 16 bytes long!"); throw new InvalidFormatException("Encoded data must be at least 16 bytes long!");
} }

Datei anzeigen

@ -42,12 +42,7 @@ public class PluginMessageUtils {
.put(data) .put(data)
.array(); .array();
data = "floodgate:skin\0floodgate:form".getBytes(Charsets.UTF_8); FLOODGATE_REGISTER_DATA = "floodgate:skin\0floodgate:form".getBytes(Charsets.UTF_8);
FLOODGATE_REGISTER_DATA =
ByteBuffer.allocate(data.length + getVarIntLength(data.length))
.put(writeVarInt(data.length))
.put(data)
.array();
} }
/** /**